collinPHP Posted July 24, 2007 Share Posted July 24, 2007 I have these variables posted in from a form text0,text1,text2,text3,text4 I use this to retrieve these variables being posted import_request_variables(gp, "formval_"); $tx0 = $formval_text0; $tx1 = $formval_text1; $tx2 = $formval_text2; $tx3 = $formval_text3; $tx4 = $formval_text4; This works perfectly, but what I want to do is this: $hn=5; $startnum=0; import_request_variables(gp, "formval_"); while ($startnum < $hn) { $text_stuff=formval_text.$startnum; echo $text_stuff; $startnum++; } This is what is outputted formval_text0formval_text1... what I want is the contents of: formval_text0 formval_text1... So, my problem arises with this line $text_stuff=formval_text.$startnum; How might I change this line to get: formval_text0 , formval_text1 , formval_text2 , ... Thank you Collin Thompson Quote Link to comment Share on other sites More sharing options...
trq Posted July 25, 2007 Share Posted July 25, 2007 $text_stuff = ${'formval_text'.$startnum}; Quote Link to comment Share on other sites More sharing options...
trq Posted July 25, 2007 Share Posted July 25, 2007 Of course if you didn't use import_request_variables() you could simply loop through the post array instead. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.