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?
什么是错误的吗?为什么array_count_values返回一个空数组?
1 个解决方案
#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
.
array_count_values仅适用于string和integer值。我的猜测是:你在“$progress”中存储布尔人。您可以在将它们添加到$progress之前将它们转换为int类型。
#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
.
array_count_values仅适用于string和integer值。我的猜测是:你在“$progress”中存储布尔人。您可以在将它们添加到$progress之前将它们转换为int类型。