note 31926 added to function.array-diff-assoc
| From: | carl at rack1 dot php dot net | Date: | Fri, 09 May 2003 07:55:19 +0000 |
| Subject: | note 31926 added to function.array-diff-assoc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47724@lists.php.net to get a copy of this message | ||
IHMO the documentation is not entirely clear so just to clarify:
This function looks at BOTH the key and the value, so you can't use it to
unset a list elements in an array if you know the keys but not the values.
Instead, you can e.g. do:
$a = array("foo", "bar", "baz", "quux");
$b = array(1, 3); // Elements to get rid of
foreach($b as $e)
unset($a[$e]);
Of course this makes most sense if $b has many elements or is dynamically generated.
--
http://www.php.net/manual/en/function.array-diff-assoc.php
http://master.php.net/manage/user-notes.php?action=edit+31926
http://master.php.net/manage/user-notes.php?action=delete+31926
http://master.php.net/manage/user-notes.php?action=reject+31926