Counting the Occurrences of a Substring : substr_count « String « PHP






Counting the Occurrences of a Substring

 
<?php 
$counter = substr_count ("Hello World!","o"); 

echo "There are " . $counter . " instance (s) of \"o\" in Hello World!."; 
?>
  
  








Related examples in the same category

1.Testing for Substrings
2.substr_count() function returns the number of times substring occurs in string.
3.substr_count.php