note 94598 deleted from function.array-search by levim
| From: | levim@php.net | Date: | Mon, 24 Feb 2014 22:44:37 +0000 |
| Subject: | note 94598 deleted from function.array-search by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-198698@lists.php.net to get a copy of this message | ||
Note Submitter: mrjay42 at gmail dot com
----
If you search a key position in an associative array (keys are uniques), i suggest this function :
<?php
public function getKeyPositionInArray($haystack, $keyNeedle)
{
$i = 0;
foreach($haystack as $key => $value)
{
if($key == $keyNeedle)
{
return $i;
}
$i++;
}
}
?>