note 16118 deleted from function.array by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 20:56:26 +0000 |
| Subject: | note 16118 deleted from function.array by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25441@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>