newb Posted July 27, 2010 Share Posted July 27, 2010 I have two arrays: $array1[$i] and $array2[$i] how can i output the contents of both in one single foreach loop? Quote Link to comment Share on other sites More sharing options...
newb Posted July 27, 2010 Author Share Posted July 27, 2010 http://www.webdeveloper.com/forum/showthread.php?t=157158 this is what im trying to do, my code is exact the same as this. does anyone have a solution? Quote Link to comment Share on other sites More sharing options...
Zane Posted July 27, 2010 Share Posted July 27, 2010 What code have you tried already? It should be as simple as the pseudo-snippet you posted already Quote Link to comment Share on other sites More sharing options...
Alex Posted July 27, 2010 Share Posted July 27, 2010 You can't do that with a foreach loop, but assuming both arrays are the same length you can use a for loop like so: for($i = 0;$n = sizeof($arr1);$i < $n;++$i) { echo $arr1[$i] . " - " . $arr2[$i] . "<br />\n"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.