Counting arrays in loop

Posted by Ivory Santos on Stack Overflow See other posts from Stack Overflow or by Ivory Santos
Published on 2012-09-01T03:23:09Z Indexed on 2012/09/01 3:37 UTC
Read the original article Hit count: 186

Filed under:
|

I have a loop...

while($rows=mysql_fetch_array($result))
    {

        $staff[] = $rows['staff'];
        $a = array_count_values($staff);
        $b = count($a);
        echo"$b<br>";

    }

that output

1
1
1
2
2
2
3
3
4
5
5

on my research, it must be and I wanted the result to be this way

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)

any help?

what I want is to get the number of same element in an array

© Stack Overflow or respective owner

Related posts about arrays

Related posts about count