ronchan Posted January 17, 2009 Share Posted January 17, 2009 I have a very long form with input numeric names. Normally I would do this to process the form: $input_1005=$_POST['1005']; $input_1006=$_POST['1006']; But since there are so many inputs (over 75) I'd rather create a WHILE loop to process this form, something like: $input_num=$_POST[echo $num;]; I know that I have the syntax wrong though. Can anyone give me some help? Thanks! Link to comment https://forums.phpfreaks.com/topic/141260-variable-inside-a-_post/ Share on other sites More sharing options...
Mchl Posted January 17, 2009 Share Posted January 17, 2009 Take a look at extract (use 'prefix all' mode) Link to comment https://forums.phpfreaks.com/topic/141260-variable-inside-a-_post/#findComment-739385 Share on other sites More sharing options...
PFMaBiSmAd Posted January 17, 2009 Share Posted January 17, 2009 If you create a named array variable in your form where the index of the array is your numeric value, you can use a simple foreach loop in your code to iterate over all the indexes and values. Form - <input type="text" name="arr[1005]"> <input type="text" name="arr[1006]"> Form processing code - foreach($_POST['arr'] as $key => $value){ echo "Key: $key, has value: $value<br />"; } Link to comment https://forums.phpfreaks.com/topic/141260-variable-inside-a-_post/#findComment-739386 Share on other sites More sharing options...
ronchan Posted January 18, 2009 Author Share Posted January 18, 2009 Thanks for the help. Using the array got me on the right track and I've figured it out. Thanks again!! Link to comment https://forums.phpfreaks.com/topic/141260-variable-inside-a-_post/#findComment-739438 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.