diff --git a/functions/array.xml b/functions/array.xml index 705867c5f4..c230b4fcb5 100644 --- a/functions/array.xml +++ b/functions/array.xml @@ -1,5 +1,5 @@ - + Array Functions Arrays @@ -202,6 +202,20 @@ $result = array_diff ($array1, $array2); array ("blue");. Multiple occurences in $array1 are all treated the same way. + + + Two elements are considered equal if and only if + (string) $elem1 === (string) $elem2. In words: + when the string representation is the same. + + + + + + This was broken in PHP 4.0.4! + + + See also array_intersect. @@ -1386,6 +1400,23 @@ echo "sum(b) = ".array_sum($b)."\n"; keep the first key encountered for every value, and ignore all following keys. + + + Two elements are considered equal if and only if + (string) $elem1 === (string) $elem2. In words: + when the string representation is the same. + + + + The first element will be used. + + + + + This was broken in PHP 4.0.4! + + + <function>array_unique</function> example @@ -1403,27 +1434,22 @@ print_r($result); - - Note that array_unique 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. - <function>array_unique</function> and types -$input = array (4,"3",3,"4",4,4); +$input = array (4,"4","3",4,3,"3"); $result = array_unique ($input); -print_r($result); -// this will output : -//Array -//( -// [0] => 3 -// [1] => 3 -// [2] => 4 -// [3] => 4 -//) +var_dump($result); + +/* output: +array(2) { + [0]=> + int(4) + [1]=> + string(1) "3" +} +*/