PHP array indexof 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 = array_search('red', $array);
?>
Example 2: php indexof
strrpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) : int
Example 3: php array get value at index
$array = array('foo' => 'bar', 33 => 'bin', 'lorem' => 'ipsum');
$array = array_values($array);
echo $array[0];
echo $array[1];
echo $array[2];
Example 4: php indexof
strrpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) : int or False return
<?php
$foo = "0123456789a123456789b123456789c";
var_dump(strrpos($foo, '0', 0));
var_dump(strrpos($foo, '0', 1));
$str = 'This is Main String';
if (strpos($str, 'This') !== false) {
echo 'true';
}