By using substr_count() function we can count the number of substring occurrences in php. substr_count() returns the number of times the needle substring occurs in the haystack string.The needle is case sensitive.

example:

$str="We are the members of tutorialsmint. We love to help others.";
echo substr_count($str,"We");

Output:

2
Written by
Check out this Author's contributed articles.
If you like Tutorialsmint and would like to contribute, you can also write an article using Write an Article. See your article appearing on the Tutorialsmint main page and help other programmers to enhance their knowledge.

Comments(0)

RECENT TUTORIALS
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Wed Dec 26 • 08:00 AM GMT
Edit Post
Add Reply