jomak73 Posted July 19, 2010 Share Posted July 19, 2010 This is probably a really simple question. Is it possible to initialize x amount of variables. Like someone enters 10 into an input box and it makes 10 variables called variable1, variable2, variable3, etc. How would you name them? $variable + num = 0; ? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/208188-initializing-x-amount-of-variables/ Share on other sites More sharing options...
Kevin.Arvixe Posted July 19, 2010 Share Posted July 19, 2010 arrays work great for this. $variable[0] = value $variable[1] = value2 or also you can do this... while($x=0; $x < 5; $x++) { foreach($_POST as $v) { $variable[$x] = $v; } } That puts all of your $_POST variables into the array $variable.... Granted thats sort of repetitive, but you get the idea right? Quote Link to comment https://forums.phpfreaks.com/topic/208188-initializing-x-amount-of-variables/#findComment-1088168 Share on other sites More sharing options...
jomak73 Posted July 19, 2010 Author Share Posted July 19, 2010 Yea i think that'll work great! Thankss Quote Link to comment https://forums.phpfreaks.com/topic/208188-initializing-x-amount-of-variables/#findComment-1088172 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.