note 13953 added to function.array-diff.php
| From: | agutsul at hotmail dot com | Date: | Wed, 11 Jul 2001 10:11:57 +0000 |
| Subject: | note 13953 added to function.array-diff.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15219@lists.php.net to get a copy of this message | ||
array_diff() seems to sort the array in ascending order (without actually changing the keys), which
can be a very annoying side effect sometimes, especially when you have the array in some special
order (e.g. based on some criteria from the db).
--
$a=array(4,5,6,2,1);
$b=array(6);
$c=array_diff($a,$b);
print_r($c);
--
produces:
Array
(
[4] => 1
[3] => 2
[0] => 4
[1] => 5
)
--
Does anyone have an elegant solution to this?
http://www.php.net/manual/en/function.array-diff.php