且构网

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

如何使用&QUOT多个阵列;单" foreach()循环

更新时间:2022-11-15 11:47:43

假设你有这两个数组相同数量的项目。

assume you have the same number of items in those two arrays.

如果你想使用的foreach(),那么阵列需要具有相同的索引:

if you want to use foreach(), then the arrays need to have the same index:

foreach ($a as $index => $value)
{
    echo $a[$index] .' '. $b[$index];
}

如果数组有数字索引,你可以使用为()

if the arrays have numeric index, you can just use for():

for ($i = 0; $i < sizeof($a); $i++)
{
    echo $a[$i] .' '. $b[$i];
}