PHP 统计数组元素个数
count();
sizeof();
这两个函数都返回数组元素的个数
$price =array('Tires'=>100,'Water'=>3);
$result =count($price);
$re =sizeof($price);
echo '元素个数'.$result;
echo '元素个数'.$re;
array_count_values();
该函数返回的是每个元素在数组中出现的频率
$array = array(1, "hello", 1, "world", "hello");
print_r(array_count_values($array));
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。