note 114756 added to function.array-search
| From: | rAthur | Date: | Wed, 02 Apr 2014 08:35:58 +0000 |
| Subject: | note 114756 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199101@lists.php.net to get a copy of this message | ||
If you're not running an older version of PHP (many servers are still on PHP 5.3), you can
replace the function by this :
<?php
function s($needle,$array)
{
foreach($array as $key => $value)
if ($value==$needle)
return $key;
return false;
}
echo s( 'c', array('a', 'b', 'c', 'd') ); //
returns 2
echo s( 'f', array('a', 'b', 'c', 'd') ); //
returns false
?>
----
Server IP: 72.52.91.14
Probable Submitter: 82.67.44.128
----
Manual Page -- http://php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/114756
Del: integrated -- https://master.php.net/note/delete/114756/integrated
Del: useless -- https://master.php.net/note/delete/114756/useless
Del: bad code -- https://master.php.net/note/delete/114756/bad+code
Del: spam -- https://master.php.net/note/delete/114756/spam
Del: non-english -- https://master.php.net/note/delete/114756/non-english
Del: in docs -- https://master.php.net/note/delete/114756/in+docs
Del: other reasons-- https://master.php.net/note/delete/114756
Reject -- https://master.php.net/note/reject/114756
Search -- https://master.php.net/manage/user-notes.php