return the index number php code example
Example 1: get index of element in array 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: how to start the index from 1 in php?
$array = array("a","b","c");
array_unshift($array,"");
unset($array[0]);