note 114756 deleted from function.array-search by cmb
| From: | cmb@php.net | Date: | Sun, 01 Sep 2019 07:57:11 +0000 |
| Subject: | note 114756 deleted from function.array-search by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212077@lists.php.net to get a copy of this message | ||
Note Submitter: rAthur
----
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
?>