Use while loop to control the strpos in PHP
Description
The following code shows how to use while loop to control the strpos.
Example
<?php/*from w w w . ja v a2 s . co m*/
$myString = "Hello, world!";
$pos = 0;
while ( ( $pos = strpos( $myString, "l", $pos ) ) !== false ) {
echo "The letter 'l' was found at position: $pos<br/>";
$pos++;
}
?>
The code above generates the following result.