我想删除group_id下面的父数字数组,并让收件人数组位于group_id之后。
[1] => Array
(
[group_id] => 1234
[0] => Array
(
[recipients] => Array
(
[0] => Array
(
[recipient_id] => 2
[name] => Another Tester
[email] => testertest@test.com
[phone] => 1230001234
)
[1] => Array
(
[recipient_id] => 10
[name] => teadsf
[email] => newguy@test.com
[phone] => 1230001234
)
答案 0 :(得分:0)
一种方法是通过一些数组修改操作来for..each
循环:
//$input is your original input array
// final output array
$output = array();
// Loop over the array
foreach ($input as $key => $value) {
$output[$key]['group_id'] = $value['group_id'];
// Set recipients key at the same level as group_id
// Access the value at [0]['recipients']
$output[$key]['recipients'] = $value[0]['recipients'];
}