Darkness Soul Posted December 5, 2006 Share Posted December 5, 2006 Yo,Is possible to mount variable name with the code? My case: I have a form with the input fields named by a prefixe and the line id, and, recover it with import_request_variables() function.Exemple:[code]form.php(...) -- ordened by the sqlinput name="detail241" value=""input name="detail23" value=""(...)action.php(...)import_request_variables ( "p" , "var_" ) ;print $var_detail241 ;(...)[/code]This $var_detail241, I haven't a way to know its number, but I need its value, all I have is a for with all Id posted and the name $var_detail, so, how do I, if its possible, to make an $var_detail+$id to make my numered variable?Thank you.D.Soul Quote Link to comment Share on other sites More sharing options...
trq Posted December 5, 2006 Share Posted December 5, 2006 Im sorry, but I can't make any sense of your post. At all. Quote Link to comment Share on other sites More sharing options...
Stooney Posted December 5, 2006 Share Posted December 5, 2006 What he's trying to say is if he can declare a variable who's name is based on other variables. Ex:[code]$num=4;$var$num="text";echo $var4; //outputs 'text'[/code]of course that doesn't work. As far as I know it's not possible. Maybe someone might know of something after I put it in English. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 5, 2006 Share Posted December 5, 2006 What you're looking for are called [url=http://www.php.net/manual/en/language.variables.variable.php]variable variables[/url].A better way of doing this is to use arrays. In the form:[code]<input name="detail[241]" value=""><input name="detail[23]" value="">[/code]In action.php[code]<?phpif isset($_POST['detail']) foreach($_POST as $key => $val) echo '$_POST[' . $key . '] = ' . $val . "<br>\n";?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
Darkness Soul Posted December 6, 2006 Author Share Posted December 6, 2006 Thank you, this are very useful!I used just one time a long ago this form array and get missed it.. :) I'm happy plus now!D.Soul 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.