deft Posted July 9, 2007 Share Posted July 9, 2007 I've got this javascript that results in the following being posted; weight_1 = 30 cost_1 = 20 amount_1 = 32 weight_3 = 65 cost_3 = 23 amount_3 = 12 weight_7 = 43 cost_7 = 9 amount_7 = 12 etc.., with the numbers appended to the keys (here 1, 3, and 7) ascending but not sequential. I need my PHP recieving these POST keys/values to present them like this: #1 Weight: 30 Cost: 20 Amount: 30 #2 Weight: 65 Cost: 23 Amount: 12 #1 Weight: 43 Cost: 9 Amount: 12 Whats' the right way to do this? I've been messing around with array functions but haven't quite figured out which to use.. Link to comment https://forums.phpfreaks.com/topic/59023-getting-keysvalues-from-post-array-in-an-orderly-fashion/ Share on other sites More sharing options...
cooldude832 Posted July 9, 2007 Share Posted July 9, 2007 this might be a bit crude for you but <?php $i = 0; foreach($_POST as $key => $value){ if(strstr($key,"weight" != "FALSE"){echo "<br/>"; $i++; echo "#".$i."<br/>";} //Above line adds the break between sub groups echo $key." = ".$value."<br/>"; } ?> Link to comment https://forums.phpfreaks.com/topic/59023-getting-keysvalues-from-post-array-in-an-orderly-fashion/#findComment-293010 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.