cvs: phpdoc /en/functions array.xml

From: Date: Thu, 12 Jul 2001 12:49:04 +0000
Subject: cvs: phpdoc /en/functions array.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969336208@lists.php.net to get a copy of this message
dams Thu Jul 12 08:49:04 2001 EDT Modified files: /phpdoc/en/functions array.xml Log: Added note about array_unique making case of value's types. Index: phpdoc/en/functions/array.xml diff -u phpdoc/en/functions/array.xml:1.80 phpdoc/en/functions/array.xml:1.81 --- phpdoc/en/functions/array.xml:1.80 Mon Jul 9 21:10:36 2001 +++ phpdoc/en/functions/array.xml Thu Jul 12 08:49:04 2001 @@ -1378,7 +1378,11 @@ <function>array_unique</function> takes input <parameter>array</parameter> and returns a new array without duplicate values. - Note that keys are preserved. + </para> + <para> + Note that keys are preserved. <function>array_unique</function> will + keep the first key encountered for every value, and ignore all + following keys. </para> <para> <example> @@ -1386,12 +1390,40 @@ <programlisting role="php"> $input = array ("a" =&gt; "green", "red", "b" =&gt; "green", "blue", "red"); $result = array_unique ($input); +print_r($result); +// this will output : +//Array +//( +// [a] => green +// [0] => red +// [1] => blue +//) </programlisting> </example> </para> <para> - This makes <varname>$result</varname> have <literal>array ("a" =&gt; - "green", "red", "blue");</literal>. + Note that <function>array_unique</function> take into account + value's type. This is usually of no matter, except when it + comes to compare numbers, which can be of several types. + This may lead to confusing results. + </para> + <para> + <example> + <title><function>array_unique</function> and types</title> + <programlisting role="php"> +$input = array (4,"3",3,"4",4,4); +$result = array_unique ($input); +print_r($result); +// this will output : +//Array +//( +// [0] => 3 +// [1] => 3 +// [2] => 4 +// [3] => 4 +//) + </programlisting> + </example> </para> </refsect1> </refentry>

« previous php.doc (#969336208) next »