<?php
$colors= array('red','blue','green','yellow','red');
$str = implode(',',$colors);
$count=substr_count($str,'red');
echo $count;
?>
php 查询字符串在数组中出现的次数
最新推荐文章于 2021-03-28 05:31:46 发布
<?php
$colors= array('red','blue','green','yellow','red');
$str = implode(',',$colors);
$count=substr_count($str,'red');
echo $count;
?>