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:

<?php
   function countSubstringInString($string, $substring){
	   $count = mb_substr_count($string, $substring);
	   return $count;
   }
   $string = "This is a test of Soltuts.com";
   $substring = "Soltuts";
	$count = countSubstringInString($string, $substring);
  echo $count;
?>
  

2. Example:

Input:

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

Output:

output: 1