note 16118 added to function.array
| From: | clark at wayport dot net | Date: | Wed, 17 Oct 2001 05:04:19 +0000 |
| Subject: | note 16118 added to function.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19021@lists.php.net to get a copy of this message | ||
RE: Remove a value from an array.
The function provided by Pete@thetgg.co.uk won't work with associative arrays.
Here is one that will:
<PRE>
function array_remove_by_key($remove_key, $array)
{
$temp_array = $array;
unset($array);
while(list($key) = each($temp_array)) {
if ($temp_array[$key] != $remove_key) {
$array["$key"] = $temp_array[$key];
}
}
return $array;
}
</PRE>
--
http://www.php.net/manual/en/function.array.php
http://master.php.net/manage/user-notes.php?action=edit+16118
http://master.php.net/manage/user-notes.php?action=delete+16118
http://master.php.net/manage/user-notes.php?action=reject+16118