时间:2021-07-01 10:21:17 帮助过:34人阅读
$data = array();
if (!empty($_POST['field_id'])) {
foreach ($_POST['field_id'] as $k => $v) {
$data[] = array(
'field_id' => $v,
'choice' => isset($_POST['choice'][$k]) ? $_POST['choice'][$k] : '',
'uid' => $_POST['uid'],
'game_id' => $_POST['game_id'],
'server_id' => $_POST['server_id']
);
}
}
Array
(
[0] => Array
(
[field_id] => 1
[choice] => 0
[uid] => 110000110
[game_id] => 2
[server_id] => 2
)
[1] => Array
(
[field_id] => 2
[choice] => 0
[uid] => 110000110
[game_id] => 2
[server_id] => 2
)
[2] => Array
(
[field_id] => 3
[choice] => 1
[uid] => 110000110
[game_id] => 2
[server_id] => 2
)
)
$data = array();
if (!empty($_POST['field_id'])) {
foreach ($_POST['choice'] as $k => $v) {
if($v == '') continue;
$data[] = array(
'field_id' => $_POST['field_id'][$k],
'choice' => $_POST['choice'][$k],
'uid' => $_POST['uid'],
'game_id' => $_POST['game_id'],
'server_id' => $_POST['server_id']
);
}
}