note 41989 deleted from function.array-search by felipe
| From: | felipe@php.net | Date: | Sun, 10 Feb 2008 13:10:41 +0000 |
| Subject: | note 41989 deleted from function.array-search by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135959@lists.php.net to get a copy of this message | ||
Note Submitter: ivan dot schmid at astalavista dot ch
----
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