get key of item array php code example
Example 1: get key of value array php
<?php
$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
$key = array_search('green', $array); // $key = 2;
$key = array_search('red', $array); // $key = 1;
?>
Example 2: get array key php
array_keys ($array);
// It returns an array
// more informations at https://www.php.net/manual/fr/function.array-keys.php (fr)