php如何统计字符串"Compiling software from source code can become very c
<?php
$word="很长一串英文";
$total=array();
foreach(explode(" ",$word) as $v){
isset($total[$v])?$total[$v]++:$total[$v]=1;
}
foreach($total as $k=>$v){
echo $k." 出现次数 ".$v."<br>";
}
?>
$word="很长一串英文";
$total=array();
foreach(explode(" ",$word) as $v){
isset($total[$v])?$total[$v]++:$total[$v]=1;
}
foreach($total as $k=>$v){
echo $k." 出现次数 ".$v."<br>";
}
?>
温馨提示:答案为网友推荐,仅供参考