Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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
3  
Working fine on codepad –  hjpotter92 Jul 12 '12 at 9:16
    
so what can the problem be on my system (php ver. 5.3)? –  Moshe Shaham Jul 12 '12 at 9:17
    
Can you show result of var_export($progress);? –  Dador Jul 12 '12 at 9:19
    
Is your error reporting turned on? –  Lix Jul 12 '12 at 9:20
add comment

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 '12 at 9:20
    
you are correct, this was the problem! –  Moshe Shaham Jul 12 '12 at 9:22
    
then mark as correct answer please ;) –  cweinberger Jul 12 '12 at 9:52
add comment

Your Answer

 
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.