note 31775 added to function.array-diff
| From: | php-general at lists dot php dot net | Date: | Sat, 03 May 2003 07:36:33 +0000 |
| Subject: | note 31775 added to function.array-diff | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47413@lists.php.net to get a copy of this message | ||
> Order appears to matter with array_diff...
> $dif = array_diff ($HTTP_POST_VARS[user], $my_list); // Gave expected results
> $dif = array_diff ($my_list, $HTTP_POST_VARS[user]); // No Results
That's right, because array_diff() takes the first given array, then removes from it any values
that are present in any of the other arrays. So your first example would remove any values in
$my_list from $_POST['vars'], whereas the second example will remove any values in
$_POST['vars'] from $my_list.
--
http://www.php.net/manual/en/function.array-diff.php
http://master.php.net/manage/user-notes.php?action=edit+31775
http://master.php.net/manage/user-notes.php?action=delete+31775
http://master.php.net/manage/user-notes.php?action=reject+31775