$结果是一个数组,看起来像这样:分组通过钥匙阵列在foreach循环
Array (
[0] => stdClass Object (
[Key_1] => a
[Key_2] => 10
)
[1] => stdClass Object (
[Key_1] => b
[Key_2] => 10
)
[2] => stdClass Object (
[Key_1] => c
[Key_2] => 20
)
)
我怎么能回声$结果通过[Key_2]分组foreach循环裹着像一个div
<div class="new_Key_2">
Key_2: 10
------------
Key_1: a
Key_1: b
</div>
<div class="new_Key_2">
Key_2: 20
------------
Key_1: c
</div>
我知道如何通过检查[Key_2]已更改为打开DIV,而不是如何前一个新的[Key_2]走来关闭。
**解析错误:**语法错误,在线路意外T_FUNCTION _ $阵列= array_reduce($阵列,..._ – joko13
什么版本的PHP您使用的是???请参阅现场演示:http://codepad.viper-7.com/xGiSXR – Baba
@ joko13如果您的php小于5.3,请使用此代码http://codepad.org/pbUI1Grz – Baba