MadnessRed Posted August 6, 2008 Share Posted August 6, 2008 ok, will have several things coming from a form, eg $_POST[cost1] $_POST[cost2] $_POST[cost4] $_POST[cost5] $_POST[cost9] $_POST[cost10] $_POST[cost15] $_POST[time1] $_POST[time2] $_POST[time4] $_POST[time5] $_POST[time9] $_POST[time10] $_POST[time15] Now, can I make an array of all the "$_POST['cost'.*]"? so that I can something like echo max(array($_POST['cost'.*]));? Link to comment https://forums.phpfreaks.com/topic/118513-solved-make-an-array-out-of-posts/ Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 First of all, use ' ' around array keys when accessing them. Second of all, how are you populating $_POST['cost1'] etc? Text inputs? Link to comment https://forums.phpfreaks.com/topic/118513-solved-make-an-array-out-of-posts/#findComment-610120 Share on other sites More sharing options...
MadnessRed Posted August 6, 2008 Author Share Posted August 6, 2008 no its hidden. $costs = ""; if ($_POST['ammount1'] >= 1){ [tab] $costs .= "<input type=\"hidden\" name=\"cost1\" value=\"20\" />"; } if ($_POST['ammount2'] >= 1){ [tab] $costs .= "<input type=\"hidden\" name=\"cost2\" value=\"15\" />"; } [ect ect ect] Link to comment https://forums.phpfreaks.com/topic/118513-solved-make-an-array-out-of-posts/#findComment-610160 Share on other sites More sharing options...
DarkWater Posted August 6, 2008 Share Posted August 6, 2008 Why not do: <input type="hidden" name="cost[1]" value="20" /> That way $_POST['cost'] will be a multi-dimensional array with what you want. Link to comment https://forums.phpfreaks.com/topic/118513-solved-make-an-array-out-of-posts/#findComment-610164 Share on other sites More sharing options...
MadnessRed Posted August 21, 2008 Author Share Posted August 21, 2008 thanks Link to comment https://forums.phpfreaks.com/topic/118513-solved-make-an-array-out-of-posts/#findComment-622546 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.