note 41989 added to function.array-search
| From: | ivandotschmidatastalavistadotch at rn2 dot php dot net | Date: | Wed, 28 Apr 2004 13:46:32 +0000 |
| Subject: | note 41989 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68949@lists.php.net to get a copy of this message | ||
This is a simple Array-search & delete example.
============================================
<?PHP
//Array I am going to look in:
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 =>
'red');
if(in_array('blue', $array))
{
unset($array[array_search('blue', $array)]); // $key = 0;
}
print_r($array);
/* Output:
Array
(
[1] => red
[2] => green
[3] => red
)
*/
?>
============================================
Hope this helps someone.
Greetings Ivan
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41989
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41989&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41989&report=yes
Search -- http://master.php.net/manage/user-notes.php