Index of / php code example
Example 1: array_search in 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 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';
}