note 13779 added to function.array.php
| From: | Pete at thetgg dot co dot uk | Date: | Mon, 02 Jul 2001 23:46:02 +0000 |
| Subject: | note 13779 added to function.array.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-14929@lists.php.net to get a copy of this message | ||
OK. What I wanted to do was to remove a value from an array, but PHP doesn't appear to support
this as a function. It's not totally comprehensive, as in it will not remove values from
indexed arrays, just basic 2D arrays, but I wrote a small function which will remove a supplied
value from an array:
// Supplied arguments:
// ------------------
// removevalue is the value you want removing.
// array is the array you want it removing from
function arrayremove($removevalue, $array)
{
$temp_array = $array;
unset($array);
for ($i=0; $i < sizeof($temp_array); $i++)
{
if($temp_array[$i] != $removevalue)
{
$array[] = $temp_array[$i];
}
}
return $array;
}
Thanks to mattbeale@ntlworld.com for the initial idea.
http://www.php.net/manual/en/function.array.php