aidan           Sun Aug 29 07:03:22 2004 EDT

  Modified files:              
    /phpdoc/en/reference/strings/functions      stripslashes.xml 
  Log:
  Added a second example which addresses a large amount of user notes about dealing 
with arrays
  
http://cvs.php.net/diff.php/phpdoc/en/reference/strings/functions/stripslashes.xml?r1=1.3&r2=1.4&ty=u
Index: phpdoc/en/reference/strings/functions/stripslashes.xml
diff -u phpdoc/en/reference/strings/functions/stripslashes.xml:1.3 
phpdoc/en/reference/strings/functions/stripslashes.xml:1.4
--- phpdoc/en/reference/strings/functions/stripslashes.xml:1.3  Thu Jul 24 04:48:10 
2003
+++ phpdoc/en/reference/strings/functions/stripslashes.xml      Sun Aug 29 07:03:21 
2004
@@ -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>
@@ -42,6 +42,57 @@
 ]]>
       </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

Reply via email to