且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在PHP中循环遍历多个数组的数组

更新时间:2023-01-16 21:37:50

使用子数组之一的索引访问所有其他子数组:

Use the indexes of one of the sub-arrays to access all the other sub-arrays:

foreach ($array['item_id'] as $i => $item_id) {
    $request_explanation = $array['request_explanation'][$i];
    $quantity = $array['quantity'][$i];
    // repeat this for all the columns
    // Now you can insert all these variables into the database
}