Array ( [图书楼] => Array ( [0] => Array ( [serial_number] => 51907180020053 [power] => 111.92 )
[1] => Array
(
[serial_number] => 11908061080007
[power] => 152.24
)
[2] => Array
(
[serial_number] => 51907180020042
[power] =>
)
[3] => Array
(
[serial_number] => 51907180020053
[power] => 111.92
)
[4] => Array
(
[serial_number] => 51907180020079
[power] => 8.91
)
[5] => Array
(
[serial_number] => 51907180020097
[power] =>
)
)
[女生宿舍] => Array
(
[0] => Array
(
[serial_number] => 51907180020046
[power] => 0.01
)
)
[男生宿舍] => Array
(
[0] => Array
(
[serial_number] => 51907180020061
[power] =>
)
)
[东侧家属院一单元] => Array
(
[0] => Array
(
[serial_number] => 11908061080017
[power] => 177.21
)
)
[东侧家属院二单元] => Array
(
[0] => Array
(
[serial_number] => 11908061080015
[power] => 111.04
)
)
[东侧家属院三单元] => Array
(
[0] => Array
(
[serial_number] => 11908061080018
[power] => 86.53
)
)
[西侧家属院一单元] => Array
(
[0] => Array
(
[serial_number] => 11908061080005
[power] => 121.20
)
)
[西侧家属院二单元] => Array
(
[0] => Array
(
[serial_number] => 11908061080011
[power] => 138.85
)
)
[西侧家属院三单元] => Array
(
[0] => Array
(
[serial_number] => 11908061080014
[power] => 59.27
)
)
[家属院一单元] => Array
(
[0] => Array
(
[serial_number] => 11908061080010
[power] => 105.90
)
)
[家属院二单元] => Array
(
)
[家属院三单元] => Array
(
[0] => Array
(
[serial_number] => 11908061080002
[power] => 104.10
)
)
[家属院] => Array
(
[0] => Array
(
[serial_number] => 11908061080006
[power] => 96.64
)
)
[餐厅] => Array
(
[0] => Array
(
[serial_number] => 51907180020067
[power] =>
)
[1] => Array
(
[serial_number] => 51907180020076
[power] =>
)
)
)、
我想得到图书楼,女生宿舍,每个健名下面的power的总和,然后让健名比如图书楼后的值直接是总和,小弟不才,这个循环不知道该咋写,求大佬指教
使用 var_export 或者 json_encode 后的数据再来,你这样没法测,不过简单的看起来,可以用 array_map+array_sum+array_column 解决
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。