note 35454 added to function.get-magic-quotes-gpc
| From: | david at giffin dot org | Date: | Mon, 01 Sep 2003 17:02:45 +0000 |
| Subject: | note 35454 added to function.get-magic-quotes-gpc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-55430@lists.php.net to get a copy of this message | ||
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;
}
----
Manual Page -- http://www.php.net/manual/en/function.get-magic-quotes-gpc.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35454
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35454&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35454&report=yes