note 24299 deleted from function.stripslashes by aidan
| From: | aidan@php.net | Date: | Sun, 29 Aug 2004 10:23:51 +0000 |
| Subject: | note 24299 deleted from function.stripslashes by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75539@lists.php.net to get a copy of this message | ||
Note Submitter: jpleveille at webgraphe dot com
----
Another function that considers string, arrays and objects :
function no_magic_quotes_gpc(&$var)
{
if (is_string($var)) {
$var = stripslashes($var);
} elseif (is_array($var)) {
foreach($var AS $key => $value) {
no_magic_quotes_gpc($var[$key]);
}
} elseif (is_object($var)) {
foreach(get_object_vars($var) AS $key => $value) {
no_magic_quotes_gpc($var->$key);
}
}
}
if (get_magic_quotes_gpc()) {
no_magic_quotes_gpc($_GET);
no_magic_quotes_gpc($_POST);
no_magic_quotes_gpc($_COOKIE);
}
Voilà !
JP.