Java J2ME JSP J2EE Servlet Android

Cook PHP: Finding the numbers of occurrence of a string in another string..

Lets consider a String

$str = "PHP is what PHP is and PHP is not what PHP is not";

Now lets try to find out the no of occurrence of the word 'PHP' in above string..


$cnt = count(explode("PHP",$str))-1;
echo $cnt;


This will print 4.

There are many alternative option to do the same this in php..