我有一个循环...
while($rows=mysql_fetch_array($result))
{
$staff[] = $rows['staff'];
$a = array_count_values($staff);
$b = count($a);
echo"$b<br>";
}
输出
1
1
1
2
2
2
3
3
4
5
5
在我的研究中,它一定是,我希望结果是这样的
3 (is equal to three 1's)
3 (is equal to three 2's)
2 (is equal to two 3)
1 (is equal to one 4)
2 (is equal to two 5's)
任何帮助?
我想要的是获取数组中相同元素的数量
答案 0 :(得分:1)
据我了解您的担忧,这应该可以解决问题:
$staff = array();
while($rows=mysql_fetch_array($result))
{
$staff[] = $rows['staff'];
}
$a = array_count_values($staff);
print_r($a);