thanx Eugene, I know what the problem was, firstly that when doing an array_diff the keys are preserved. Therefore If I was looping through $arrayResult for the count of elements (in this case 2) then thats where the blank value comes in. SO therefore if I wanted to get all the values out of the $arrayResult that are not blank, would I loop through the array the amount of times that there are elements in the $array1, because $arrayResult will be the same size as $array1 and also because the keys are preserved?
Im not sure if Im heading in the right direction, with regards to gettig the values out the $arrayResult. TIA. -----Original Message----- From: Eugene Lee [mailto:[EMAIL PROTECTED] Sent: Thursday, October 02, 2003 11:09 AM To: [EMAIL PROTECTED] Subject: Re: [PHP] array_diff 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 ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php