PHP Array Search
To search an array, use the
array_search
function.
It returns the key of the found element.
See the example:
<?php
$arr = [1 => 'a', 2 => 'b', 3 => 'c'];
$key = array_search('b', $arr);
echo $key;
?>
Code execution result:
2