note 93103 added to function.array-search

From: Date: Sun, 23 Aug 2009 17:18:24 +0000
Subject: note 93103 added to function.array-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-159815@lists.php.net to get a copy of this message
You can remove some values from array, by using unset() and array_search(). <?php $friends = array( 'Bob', 'Ann', 'Peter' ); // Two persons named 'Bob' $find = 'Bob'; $key = array_search( $find, $friends ); // Find key of given value if ($key != NULL || $key !== FALSE) { unset($friends[$key]); // remove key from array } // Now, $friends = array( 'Ann', 'Peter'); ?> ---- Server IP: 64.71.164.2 Probable Submitter: 113.22.134.58 ---- Manual Page -- http://www.php.net/manual/en/function.array-search.php Edit -- https://master.php.net/note/edit/93103 Del: integrated -- https://master.php.net/note/delete/93103/integrated Del: useless -- https://master.php.net/note/delete/93103/useless Del: bad code -- https://master.php.net/note/delete/93103/bad+code Del: spam -- https://master.php.net/note/delete/93103/spam Del: non-english -- https://master.php.net/note/delete/93103/non-english Del: in docs -- https://master.php.net/note/delete/93103/in+docs Del: other reasons-- https://master.php.net/note/delete/93103 Reject -- https://master.php.net/note/reject/93103 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159815) next »