count - array for specified values

tealcsg
10:20:10
Hello,

Can somebody help me?
I heave an array with numbers ($value=array(0, 2, 5, 56, 1800, 0, 36, 0, 89).
How can I count - only how many zeros is in array?

Any help will be appreciated.
smo1234
10-20-2010
array_count_values
tealcsg
10-20-2010
In that case I get information about all numbers in array and how can I use the result!? I need numbers of zeros as a variable and like that use it in the script. I don't know how to do that from that result.
Can you help? How can I put zeros in a variable in that case?
My code:
$kolicina=array(0, 2, 5, 56, 1800, 0, 36, 0, 89);
$new_array=array_count_values($kolicina);
while (list ($key, $val) = each ($new_array)) {
echo "$key -> $val <br>";
}

And result:
0 -> 3
2 -> 1
56 -> 1
1800 -> 1
36 -> 1
89 -> 1

I need information only about zeros.

thx
smo1234
10-20-2010
$kolicina=array(0, 2, 5, 56, 1800, 0, 36, 0, 89);
$new_array=array_count_values($kolicina);
echo $new_array[0];
tealcsg
10-21-2010
yes,
works exactly as I wanted.

thx
Please Login to post your reply or start a new topic