note 23243 deleted from function.array-diff by jmcastagnetto
| From: | jmcastagnetto@php.net | Date: | Tue, 06 Aug 2002 20:13:03 +0000 |
| Subject: | note 23243 deleted from function.array-diff by jmcastagnetto | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-34414@lists.php.net to get a copy of this message | ||
Array_diff has a bugged behaviour with while+list+each loops, I didn't try with foreach so I
don't know really how it'd react. So as follows:
/* Two arrays do diff */
$array_one = Array(1,2,3);
$array_two = Array(1,2);
/* Bugged behaviour*/
while( list(,$value) = @each(array_diff($array_one, $array_two)) )
echo $value."\n";
/* But this while loop never ends ... If the array_diff returns just one value , why is it never
ending?*/
/* WorkAround */
$array_diffed = array_diff($array_one, $array_two);
while( list(,$value) = @each($array_diffed) )
echo $value."\n";
Soroso J Moriarty