dongqian2021
2014-01-14 07:56
浏览 246
已采纳

使用foreach循环同时循环通过两个多维数组

i am trying to loop through two multi-dimensional array with a foreach loop

[array1] => Array ( 
[0] => Array ( 1,2,3 ) 
[1] => Array ( 4,5,6 ) 
[2] => Array ( 7,8,9 )
  )
[array2] => Array ( 
[0] => Array ( 1,2,3 ) 
[1] => Array ( 4,5,6 ) 
[2] => Array ( 7,8,9 ) ) 
  )

both has same keys,

i want to access 1st array of both arrays at same time, i want to do something like this

foreach($array1 as $key1=>$value1 && $array2 as $key2=>$value2)
    echo $value1[1]."  ".$value2[2]

its not correct, but that's what i want to do !!

图片转代码服务由CSDN问答提供 功能建议

我试图用foreach循环遍历两个多维数组</ p> < pre> [array1] =&gt; 数组( [0] =&gt;数组(1,2,3) [1] =&gt;数组(4,5,6) [2] =&gt;数组(7,8,9) ) [array2] =&gt; 数组( [0] =&gt;数组(1,2,3) [1] =&gt;数组(4,5,6) [2] =&gt;数组(7,8,9) ) ) </ code> </ pre>

两者都有相同的键,</ p>

我想同时访问两个数组的第一个数组, i想做类似的事情</ p>

  foreach($ array1 as $ key1 =&gt; $ value1&amp;&amp; $ array2 as $ key2 =&gt; $ value2)\  n echo $ value1 [1]。“”。$ value2 [2] 
 </ code> </ pre> 
 
 

它不正确,但这就是我想做的事情!</ p> </ div>

3条回答 默认 最新

相关推荐 更多相似问题