frozenlight777 Posted May 29, 2008 Share Posted May 29, 2008 I have 2 arrays that i need to loop through at the same time. Each array has the same number of values. I'm thinking of something like this.... while (list(, $value , $value2) = each($_POST['Asset_Tag'], $_POST['Service_Tag'])) { echo "Value: $value : $value2 <br />\n"; } exit; 2 loops works fine but i need it in 1... is it possible? Link to comment https://forums.phpfreaks.com/topic/107795-solved-loop-through-2-arrays/ Share on other sites More sharing options...
BlueSkyIS Posted May 29, 2008 Share Posted May 29, 2008 might work: $total_elements = count($_POST['Asset_Tag']); for ($i=0;$i<$total_elements;$i++) { $value = $_POST['Asset_Tag'][$i]; $value2 = $_POST['Service_Tag'][$i]; echo "Value: $value : $value2 <br />\n"; } Link to comment https://forums.phpfreaks.com/topic/107795-solved-loop-through-2-arrays/#findComment-552559 Share on other sites More sharing options...
frozenlight777 Posted May 29, 2008 Author Share Posted May 29, 2008 wow.. works great... thanks! Link to comment https://forums.phpfreaks.com/topic/107795-solved-loop-through-2-arrays/#findComment-552602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.