note 35454 deleted from function.get-magic-quotes-gpc by aidan
| From: | aidan@php.net | Date: | Tue, 06 Jul 2004 06:20:08 +0000 |
| Subject: | note 35454 deleted from function.get-magic-quotes-gpc by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72694@lists.php.net to get a copy of this message | ||
Note Submitter: david@giffin.org
----
Here is a working example which handles nested arrays nicely:
/*
* @author David Giffin
*
* @param value mixed Value from Get, Post or Cookie
* @return mixed Value with stripped slashes if necessary
*
*/
function &handleMagicQuotes(&$value) {
if (get_magic_quotes_gpc()) {
if (is_array($value)) {
$result = array();
foreach ($value as $k => $v) {
if (is_array($v)) {
$result[$k] = $this->handleMagicQuotes($v);
} else {
$result[$k] = stripslashes($v);
}
}
return $result;
} else {
return stripslashes($value);
}
}
return $value;
}