Re: array_diff
| From: | Eugene Lee | Date: | Thu, 02 Oct 2003 09:08:49 +0000 |
| Subject: | Re: array_diff | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-164710@lists.php.net to get a copy of this message | ||
On Thu, Oct 02, 2003 at 10:44:15AM +0200, Angelo Zanetti wrote:
:
: I am getting some weird results when using the array_diff() function.
:
: eg: $arrayResult = array_diff($array1, $array2);
:
: When i use it the resulting array ($arrayResult) gets the correct number of
: elements, however when I echo the elements in $arrayResult it contains some
: blank values.
:
: eg:
:
: $array1 = [123] [120] [44] [54]
: $array2 = [120] [54]
:
: then when I display $arrayResult:
: [123] ... -> blank value which should be 44.
It works for me:
<?php
$arr1 = array(123, 120, 44, 54);
$arr2 = array(120, 54);
$arr3 = array_diff($arr1, $arr2);
print_r($arr3);
?>
with the output:
Array
(
[0] => 123
[2] => 44
)