Moshe Shaham
Moshe Shaham

Reputation: 15984

PHP array_count_values returning an empty array

Maybe I missed something really obvious but this code doesn't work:

<pre>
<?php print_r(($progress)); ?>
<?php print_r(array_count_values ($progress)); ?>
</pre>

The output is this:

Array
(
    [0] => 1
    [1] => 1
    [2] => 1
    [3] => 1
    [4] => 1
    [5] => 1
    [6] => 1
)
Array
(
)

what is wrong here? why array_count_values returning an empty array?

Upvotes: 2

Views: 1011

Answers (1)

cweinberger
cweinberger

Reputation: 3588

array_count_values only works with string and integer values. My guess: you are storing booleans inside $progress. You could cast them to int before adding them to $progress.

Upvotes: 5

Related Questions