Fri, 17 May 2024


How to count the number of substring occurencies?

By: Anton, NetArt Media
Wed, 15 April 2020

You may use the special PHP function substr_count

<?php

$myText=" the car is red ";

echo substr_count($myText,"is");

?>

will display:

2


Category: PHP Examples
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox