I need to count the number of occurences of the substring in a string.
my code like,
$str1 = "when he arrives, he want to open the door.";
$find_str = "he";
here the string "he" is occured 4 times.
how can i find it in php?..
I need to count the number of occurences of the substring in a string.
my code like,
$str1 = "when he arrives, he want to open the door.";
$find_str = "he";
here the string "he" is occured 4 times.
how can i find it in php?..
Make use of the substr_count php function.
Solution:
$str1 = "when he arrives, he want to open the door.";
$find_str = "he";
substr_count($str1, $find_str);