Home  >  Article  >  Backend Development  >  foreach如何同时处理多个数组

foreach如何同时处理多个数组

WBOY
WBOYOriginal
2016-06-13 13:14:231277browse

foreach怎么同时处理多个数组
比如我有三个数组$array_a $array_b $array_c

我的要求是:每次foreach都能同时输出每个数组的一项

类似于这样

foreach($array_a as $a;$array_b as $b;$array_c as $c;){
echo $a." ".$b." ".$c;
}

当然上面foreach后括号里的语法应该是错的,那么应该怎么实现?

------解决方案--------------------
foreach 不是同样的意思么
foreach($array_a as $k=>$v){ 
echo $v." ".$array_b[$k]." ".$array_c[$k] ."
"; 
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn