我有这个数组结果:
Array
(
[homeclub] => Array
(
[0] => MAGA
[1] => AGUI
[2] => BRAV
[3] => TIBU
)
[homeclub_annotation] => Array
(
[0] => 3
[1] => 11
[2] => 0
[3] => 8
)
[game_inning] => Array
(
[0] => 9 inn
[1] => 10 inn
[2] => 1 inn
[3] => 10 inn
)
[visitor] => Array
(
[0] => CARI
[1] => LEON
[2] => TIGR
[3] => CARD
)
[visitor_annotation] => Array
(
[0] => 2
[1] => 10
[2] =>
[3] => 10
)
[status] => Array
(
[0] => FIN
[1] => FIN
[2] => SUSP
[3] => FIN
)
)
我需要构建一个这样的句子(以每个子数组的位置 0 为例):
INSERT INTO tbl_games (teamA, teamA_annotation, teamB, teamB_annotation, game_date, game_time, game_place, game_status)
VALUES(`MAGA`,
`3`,
`9 inn`,
`CARI`,
`2`,
NOW(),
NULL,
NULL,
`FIN`);
如何为每个子阵列获得正确的位置?请注意,要构建的句子从子数组和同一位置获取值,我应该使用 foreach 还是 for?对此有什么帮助吗?