Updated example to handle "deep" arrays

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@162778 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Aidan Lister 2004-07-06 22:42:47 +00:00
parent 7041853c56
commit f01da4d71d

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.9 $ -->
<!-- $Revision: 1.10 $ -->
<!-- splitted from ./en/functions/info.xml, last change in rev 1.2 -->
<refentry id="function.get-magic-quotes-gpc">
<refnamediv>
@ -70,9 +70,18 @@ $sql = "INSERT INTO lastnames (lastname) VALUES ('$lastname')";
<![CDATA[
<?php
if (get_magic_quotes_gpc()) {
$_POST = array_map('stripslashes', $_POST);
$_GET = array_map('stripslashes', $_GET);
$_COOKIE = array_map('stripslashes', $_COOKIE);
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}
]]>
</programlisting>