note 107288 deleted from function.array-search by levim
| From: | levim@php.net | Date: | Mon, 24 Feb 2014 22:35:14 +0000 |
| Subject: | note 107288 deleted from function.array-search by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198636@lists.php.net to get a copy of this message | ||
Note Submitter: nateferrero at gmail dot com
----
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++;
}
}