How to count how many times a substring occurs in a string in PHP?
Here the PHP substr_count() function is used.
The PHP substr_count() function is used to find out how many times a given substring is appears or repeated inside a string.
<?php $quote = "Try not to become a man of success, but rather try to become a man of value."; echo substr_count($quote, 'man'); // Outputs: 2 ?>