Php 如何更改数组和求和值的格式?
如果我有以下格式的数组:Php 如何更改数组和求和值的格式?,php,format,Php,Format,如果我有以下格式的数组: Array ( [0] => Array ( [0] => Array ( [count(*)] => 7 ) ) [1] => Array ( [0] => Array ( [count(*)] => 1 ) ) [2] => Array ( [0] =>
Array (
[0] => Array (
[0] => Array (
[count(*)] => 7
)
)
[1] => Array (
[0] => Array (
[count(*)] => 1
)
)
[2] => Array (
[0] => Array (
[count(*)] => 1
)
)
)
如何按以下格式返回:
# What I need to capture into the new array:
# [count(*)] => 7 , [count(*)] => 1, [count(*)] => 1
# So the values would be summed from the sub-arrays:
# 7+1+1 = 9
# The array would end up with just one value in it which is the sum
Array(
[0] => 9
)
我只想从该数组中获取总计数,有什么想法吗?您能更具体地说明您试图如何更改格式吗?可能使用实际的PHP代码?如果您试图对
count(*)
键的值求和,结果将是9,而不是10。如果这不是你想要做的,那么不清楚是什么。你有没有自己的代码来展示你迄今为止所做的尝试?这里的人会帮你写代码,但不会帮你写。对不起,这是我的错。我正在尝试对计数(*)的值求和,该计数可能重复