php index 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: php indexof
strrpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) : int
Example 3: how to start the index from 1 in php?
$array = array("a","b","c");
array_unshift($array,"");
unset($array[0]);