0
所以我在PHP中有這個數組。PHP合併值相同的數組
$arr = [
[ 'sections' => [1], 'id' => 1 ],
[ 'sections' => [2], 'id' => 1 ],
[ 'sections' => [3], 'id' => NULL ],
[ 'sections' => [4], 'id' => 4 ],
[ 'sections' => [5], 'id' => 4 ],
[ 'sections' => [6], 'id' => 4 ]
];
我要合併的「身份證」,並得到類似
$arr = [
[ 'sections' => [1, 2], 'id' => 1 ],
[ 'sections' => [3], 'id' => NULL ],
[ 'sections' => [4, 5, 6], 'id' => 4 ]
];
只是努力讓我的頭圍繞這一個。
這還不清楚。也許不同的鍵名會有幫助? – 2015-02-06 16:22:01
你從哪裏得到方括號?這是一個數組的完整wrogn格式! – 2015-02-06 16:28:26
@ AntonyD'Andrea:你試過了嗎? PHP 5.4。 – AbraCadaver 2015-02-06 16:29:06