How to get the position of a key within an array
$i = array_search(‘blah’, array_keys($array));
$i = array_search(‘blah’, array_keys($array));
If you have a value and want to find the key, use array_search() like this: $arr = array (‘first’ => ‘a’, ‘second’ => ‘b’, ); $key = array_search (‘a’, $arr); $key will now contain the key for value ‘a’ (that is, ‘first’).