mfischer                Sat May 18 05:55:41 2002 EDT

  Modified files:              
    /phpdoc/en/reference/array/functions        array-merge.xml 
  Log:
  - More outlining that numeric keys are preservered.
  
  
Index: phpdoc/en/reference/array/functions/array-merge.xml
diff -u phpdoc/en/reference/array/functions/array-merge.xml:1.4 
phpdoc/en/reference/array/functions/array-merge.xml:1.5
--- phpdoc/en/reference/array/functions/array-merge.xml:1.4     Sun May 12 04:19:28 
2002
+++ phpdoc/en/reference/array/functions/array-merge.xml Sat May 18 05:55:41 2002
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
 <!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
   <refentry id="function.array-merge">
    <refnamediv>
@@ -20,10 +20,11 @@
      the end of the previous one.  It returns the resulting array.
     </para>
     <para>
-     If the input arrays have the same string keys, then the later
-     value for that key will overwrite the previous one.  If, however,
-     the arrays have the same numeric key, the later value will not
-     overwrite the original value, but will be appended.
+     If the input arrays have the same string keys, then the later value for
+     that key will overwrite the previous one.  If, however, the arrays
+     contain numeric keys, the later value will <emphasis
+     role="strong">not</emphasis> overwrite the original value, but will be
+     appended.
     </para>
     <para>
      <example>
@@ -48,6 +49,49 @@
     [3] => b
     [shape] => trapezoid
     [4] => 4
+)
+]]>
+       </screen>
+      </para>
+     </example>
+    </para>
+    <para>
+     <example>
+      <title>Simple <function>array_merge</function> example</title>
+      <programlisting role="php">
+<![CDATA[
+$array1 = array();
+$array2 = array(1 => "data");
+$result = array_merge($array1, $array2);
+]]>
+      </programlisting>
+      <para>
+       Don't forget that numeric keys will be renumbered!
+       <screen role="php">
+<![CDATA[
+Array
+(
+    [0] => data
+)
+]]>
+       </screen>
+      </para>
+      <para>
+       If you want to completely preserve the arrays and just want to append
+       them to each other, use the <literal>+</literal> operator:
+       <programlisting role="php">
+<![CDATA[
+$array1 = array();
+$array2 = array(1 => "data");
+$result = $array1 + $array2;
+]]>
+       </programlisting>
+       The numeric key will be preserved and thus the association remains.
+       <screen role="php">
+<![CDATA[
+Array
+(
+    [1] => data
 )
 ]]>
        </screen>


Reply via email to