Possible Duplicate:
Multiple index variables in PHP foreach loop
I am trying to create a before and after image display using mysqli, php and html. I am pulling the records from the db with mysqli and php, and am trying to view the results in an Unordered List using a foreach loop.
I have my 2 arrays which are created above in a while loop of a mysqli query. The array will only contain 5 results (for pagination, may change later).
$before_array[] = '
<div class="highslide-gallery">
<li>
<a href="'.$beforeurl.'" class="highslide" onclick="return hs.expand(this)">
<img src="'.$beforeurl.'" width="100px" height="125px" alt="Highslide JS">
</a>
</li>';
$after_array[] = '
<li><a href="'.$afterurl.'" class="highslide" onclick="return hs.expand(this)">
<img src="'.$afterurl.'" width="100px" height="125px" alt="Highslide JS">
</a>
</li>';
and in the view of the page I have the following code to display the before and after pictures.
<div id="hoverwrap">
<ul class="hoverbox">;
<?php
foreach ($before_array as $value) {
echo $value;
}
foreach ($after_array as $value) {
echo $value;
}
?>
</ul>
</div><!-- end of hoverwrap div-->
With the current code it is displaying the pictures : before - before - before - before - before - after - after - after - after - after.
Where I would like it to diplay: before - after - before - after etc etc.
I was thinking a while loop but no matter which way I try and implement it, it results in a similiar display. Any help or pointers in the right direction will be greatly appreciated.
Thanks.