2

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?

4
  • 3
    Working fine on codepad Commented Jul 12, 2012 at 9:16
  • so what can the problem be on my system (php ver. 5.3)? Commented Jul 12, 2012 at 9:17
  • Can you show result of var_export($progress);? Commented Jul 12, 2012 at 9:19
  • Is your error reporting turned on? Commented Jul 12, 2012 at 9:20

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

It would raise an error... But if error reporting is off.. this might just be the problem...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.