<?php
$offset = 0;
$find = "is";
$find_length = strlen($find);
$string = "This is a string, and it is an example.";
while($string_position = strpos($string, $find, $offset)){
echo $find. " Found at ". $string_position ."<br>";
$offset = string_position + find_length;
}
?>
keeping getting “is Found at 2″ over and over . i am expecting ” is found at 2″, then 5, then 25
Use variables instead of constants
If the needle is found at the beginning of the string,
strpos()returns0, which means, that the loop will never start.Additional change your error settings in your development environment
Now you will get this as notice