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?

share|improve this question

64% accept rate
3  
Working fine on codepad – The DOCTOR from TARDIS Jul 12 at 9:16
so what can the problem be on my system (php ver. 5.3)? – Moshe Shaham Jul 12 at 9:17
Can you show result of var_export($progress);? – Dador Jul 12 at 9:19
Is your error reporting turned on? – Lix Jul 12 at 9:20
feedback

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
2  
It would raise an error... But if error reporting is off.. this might just be the problem... – Lix Jul 12 at 9:20
you are correct, this was the problem! – Moshe Shaham Jul 12 at 9:22
then mark as correct answer please ;) – harakiri Jul 12 at 9:52
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.