How to count the occurrence of substring in a string with PHP

1 Answer

0 votes
$s = "php c c++ python php php java php";

$substr = "php";

$count = substr_count($s, $substr);

echo $count;



/*
run:

4

*/

 



answered Oct 24, 2020 by avibootz
...