I am aware of array_walk() and array_map(). However when using the former like so (on an old project) it failed
array_walk($_POST,
http://php.net/manual/en/function.array-walk.php says that array_walk will call the function with 2 arguments, the value and the key. You should write a new function to wrap mysql_real_escape_string. Something like:
function wrapper($val, $key){
return mysql_real_escape_string($val);
}
And then:
array_walk($_POST, 'wrapper');
Sorry if my PHP is not correct, but I think you'll catch the general idea.