1
我有以下陣列,這是嵌套在一個更大的陣列陣列的負載:與嵌套計數數組的值
Array
(
[0] => Array
(
[vote_for] => 15
)
[1] => Array
(
[vote_for] => 15
)
[2] => Array
(
[vote_for] => 15
)
[3] => Array
(
[vote_for] => 5
)
[4] => Array
(
[vote_for] => 5
)
[5] => Array
(
[vote_for] => 2
)
[6] => Array
(
[vote_for] => 2
)
[7] => Array
(
[vote_for] => 2
)
[8] => Array
(
[vote_for] => 2
)
[9] => Array
(
[vote_for] => 2
)
[10] => Array
(
[vote_for] => 2
)
[11] => Array
(
[vote_for] => 2
)
[12] => Array
(
[vote_for] => 2
)
[13] => Array
(
[vote_for] => 2
)
[14] => Array
(
[vote_for] => 2
)
)
我想要做array_count_values的此陣列上的等價物,使得我得到15 => 3
,5 => 2
和2 => 10
。我如何取消嵌套數組來做到這一點?
感謝PhpMyCoder工作。我從一個不同的方法開始,然後在中途改變,忘記更新'foreach()'到不同的級別。非常感激! – David 2012-07-29 02:52:35
謝謝大衛,完美的答案。 – dplanet 2012-07-29 03:04:42