php find index of string in array 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: find index of a character in a string php
<?php
echo strpos("I love php, I love php too!","php");
?>