count函数统计数组元素出现次数!

count函数统计数组元素出现次数!

 

<?php
/**
 * QQ:5871029 Email:hel8@vip.qq.com
 * @copyright Horleun (c)2010
 * @author Horleun <Horleun@foxmail.com>
 */
$qq=array(“5”,’8′,’7′,’1′,’0′,’2′,’9′);
$n=count($qq);
echo “我的QQ是” . $n . “位的!<br/>”;

echo count(null);
echo”<br/>”;
echo count(false);

$qq2=array(‘1′,’1′,’0′,’0′,’2′,’2′,’3′,’3′,’1′,’1’);
print_r(array_count_values($qq2)); //统计各个元素出现次数!
?>

count函数统计数组元素出现次数!

结果~:

 我的QQ是7位的!
0
1Array ( [1] => 4 [0] => 2 [2] => 2 [3] => 2 )

留下回复