mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
Added a second example which addresses a large amount of user notes about dealing with arrays
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@167545 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
66100e7cac
commit
28b9801273
1 changed files with 52 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.stripslashes">
|
||||
<refnamediv>
|
||||
|
@ -43,6 +43,57 @@ echo stripslashes($str);
|
|||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
<function>stripslashes</function> is not recursive. If you want to apply
|
||||
this function to a mutli-dimensional array, you need to use a recursive function.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<example>
|
||||
<title>Using <function>stripslashes</function> on an array</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function stripslashes_deep($value)
|
||||
{
|
||||
$value = is_array($value) ?
|
||||
array_map('stripslashes_deep', $value) :
|
||||
stripslashes($value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
// Example
|
||||
$array = array('f\'oo', 'b\'ar', array('fo\'o', 'b\'ar'));
|
||||
$array = stripslashes_deep($array);
|
||||
|
||||
// Output
|
||||
print_r($array);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Array
|
||||
(
|
||||
[0] => f'oo
|
||||
[1] => b'ar
|
||||
[2] => Array
|
||||
(
|
||||
[0] => fo'o
|
||||
[1] => b'ar
|
||||
)
|
||||
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
For more information about "magic quotes", see <function>get_magic_quotes_gpc</function>.
|
||||
</para>
|
||||
<simpara>
|
||||
See also <function>addslashes</function> and
|
||||
<function>get_magic_quotes_gpc</function>.
|
||||
|
|
Loading…
Reference in a new issue