我试图在忽略大小写的情况下计算给定单词的出现次数。我试过了
<?php
$string = 'Hello World! EARTh in earth and EARth';//string to look into.
if(stristr($string, 'eartH')) {
echo 'Found';// this just show eartH was found.
}
$timesfound = substr_count($string, stristr($string, 'eartH'));// this count how many times.
echo $timesfound; // this outputs 1 instead of 3.