note 107288 added to function.array-search
| From: | nateferrero at gmail dot com | Date: | Fri, 27 Jan 2012 16:56:09 +0000 |
| Subject: | note 107288 added to function.array-search | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-185767@lists.php.net to get a copy of this message | ||
I built a function to find the numeric index of a key in an array.
<?php
/**
* Array key index
* @author Nate Ferrero
*/
function array_key_index(&$arr, $key) {
$i = 0;
foreach(array_keys($arr) as $k) {
if($k == $key) return $i;
$i++;
}
}
----
Server IP: 69.147.83.197
Probable Submitter: 76.25.189.145
----
Manual Page -- http://www.php.net/manual/en/function.array-search.php
Edit -- https://master.php.net/note/edit/107288
Del: integrated -- https://master.php.net/note/delete/107288/integrated
Del: useless -- https://master.php.net/note/delete/107288/useless
Del: bad code -- https://master.php.net/note/delete/107288/bad+code
Del: spam -- https://master.php.net/note/delete/107288/spam
Del: non-english -- https://master.php.net/note/delete/107288/non-english
Del: in docs -- https://master.php.net/note/delete/107288/in+docs
Del: other reasons-- https://master.php.net/note/delete/107288
Reject -- https://master.php.net/note/reject/107288
Search -- https://master.php.net/manage/user-notes.php