我有以下关联数组
Array (
[0] => Array
(
[0] => Liane Lanford
[1] => Ken Christenson
[2] => Melissa Jaramillo
)
[1] => Array
(
[0] => $310.40
[1] => $134.75
[2] => $951.78
)
[2] => Array
(
[0] => $0.00
[1] => $0.00
[2] => $0.00
)
[3] => Array
(
[0] => $325.92
[1] => $141.49
[2] => $999.37
)
)
数组中有 3 个客户。数量可以是 4,5 或更多。我想将数组中的数据插入到数据库中,如下表
我该如何编写 foreach 循环。我尝试了以下但不工作
foreach ($array as $payment_type => $payment) {
foreach ($array[payment_type] as $pay => $value) {
mysqli_query($link, "INSERT INTO table(name,subtotal,holdback,total) VALUES ('$pay[0]','$pay[1]','$pay[2]','$pay[3]') ");
}
}
慕婉清6462132
扬帆大鱼