In Java, we can use indexOf and lastIndexOf. Since those functions don\'t exist in PHP, what would be the PHP equivalent of this Java code?
indexOf
lastIndexOf
<
This is the best way to do it, very simple.
$msg = "Hello this is a string"; $first_index_of_i = stripos($msg,'i'); $last_index_of_i = strripos($msg, 'i'); echo "First i : " . $first_index_of_i . PHP_EOL ."Last i : " . $last_index_of_i;