[Ticket] => Array
(
[id] => Array
(
[1] => 5
[2] => 6
)
[passenger_name] => Array
(
[1] => ticket
[2] => ticket2
)
[age] => Array
(
[1] => 2
[2] => 10
)
[gender] => Array
(
[1] => Female
[2] => Male
)
)
这是我的数组输出,我想在票证表上保存数据两个条目
答案 0 :(得分:0)
首先按照蛋糕期望构建数组 -
$tickets = array(
'id' => array (
1 => 5,
2 => 6
),
'passenger_name' => array
(
1 => 'ticket',
2 => 'ticket2'
),
'age' => array
(
1 => 2,
2 => 10
),
'gender' => array
(
1 => 'Female',
2 => 'Male'
)
);
foreach ($tickets as $key => $ticket) {
foreach ($ticket as $newKey => $value) {
$newTickets[$newKey]['Ticket'][$key] = $ticket[$newKey];
}
}
然后保存数组 - $newTickets