How to count the number of substring using mb_substr_count() in php?

In PHP, we can use the function mb_substr_count() to count the total number of substrings in a given string.

1. Code:

   function countSubstringInString($string, $substring){
	   $count = mb_substr_count($string, $substring);
	   return $count;
   $string = "This is a test of";
   $substring = "Soltuts";
	$count = countSubstringInString($string, $substring);
  echo $count;

2. Example:


string: "This is a test of";
substring: Soltuts


output: 1