PHP AddSlashes to an Array
Author: Alan Reddan
February 2006
Say you have a $_POST array and and you don't know if magic quotes is on:
Then simply call this routine and your entire array is reslashed if magic quotes are off or its left alone if they are turned on.
array_walk($_POST, 'reslash_multi');
function reslash_multi(&$val,$key)
{
if (is_array($val)) array_walk($val,'reslash_multi',$new);
else {
$val = reslash($val);
}
}
function reslash($string)
{
if (!get_magic_quotes_gpc())$string = addslashes($string);
return $string;
}