[PHP-DOC] cvs: phpdoc /en/functions array.xml From: Damien Seguy (dams <email protected>)
Date: 05/16/01

dams Wed May 16 01:36:09 2001 EDT

  Modified files:
    /phpdoc/en/functions array.xml
  Log:
  Added Thomas's contribution, plus more details on array_flip.
  
Index: phpdoc/en/functions/array.xml
diff -u phpdoc/en/functions/array.xml:1.67 phpdoc/en/functions/array.xml:1.68
--- phpdoc/en/functions/array.xml:1.67 Mon Apr 23 02:03:32 2001
+++ phpdoc/en/functions/array.xml Wed May 16 01:36:08 2001
@@ -270,9 +270,22 @@
      </funcprototype>
     </funcsynopsis>
     <para>
- <function>Array_flip</function> returns an array in flip order.
+ <function>array_flip</function> returns an array in flip order,
+ i.e. keys from <parameter>trans</parameter> become values and
+ <parameter>trans</parameter>'s values become keys.
+ Note that <function>array_flip</function> works only with string
+ and integer values, and it will display an alert if it detects
+ invalid key or value (array, double, object, boolean).
     </para>
     <para>
+ If a value has several occurences, the latest key will be
+ used as its values, and all others will be lost.
+ </para>
+ <para>
+ <function>array_flip</function> returns <literal>FALSE</literal>
+ if it fails.
+ </para>
+ <para>
      <example>
       <title><function>Array_flip</function> example</title>
       <programlisting role="php">
@@ -281,6 +294,16 @@
       </programlisting>
      </example>
     </para>
+ <para>
+ <example>
+ <title><function>Array_flip</function> example : collision</title>
+ <programlisting role="php">
+$trans = array ("a" => 1, "b" => 1, "c" => 2);
+$trans = array_flip ($trans);
+// now $trans is : array(1 => "b", 2 => "c");
+ </programlisting>
+ </example>
+ </para>
    </refsect1>
   </refentry>
 
@@ -1011,9 +1034,9 @@
      </example>
     </para>
     <para>
- This makes <varname>$result</varname> have <literal>array
- (array ("green", "red"), 4.0, "php")</literal>. But
- <varname>$result2[0]</varname> is still
+ This makes both <varname>$result</varname> and <varname>$result_keyed</varname>
+ be <literal>array(array ("green", "red"), 4.0, "php")</literal>. But
+ <varname>$result_keyed[0]</varname> is still
      <literal>"php"</literal>.
     </para>
     <note>