aebstract Posted May 2, 2010 Share Posted May 2, 2010 What's the method for creating a variable using another variable in the name of it? For instance: for ($variable = 1; $variable <= 9; $variable++) { I want to create the following: $var1 $var2 $var3 etc The number being generated off of "$variable" Link to comment https://forums.phpfreaks.com/topic/200463-create-variable-name-with-variable-in-it/ Share on other sites More sharing options...
Ken2k7 Posted May 2, 2010 Share Posted May 2, 2010 That is just a bad idea. Use an array or something. But if you must, ${"var".$variable}. Link to comment https://forums.phpfreaks.com/topic/200463-create-variable-name-with-variable-in-it/#findComment-1051972 Share on other sites More sharing options...
Zane Posted May 2, 2010 Share Posted May 2, 2010 for($variable = 0; $variable ${"var" . $variable} = $variable; Link to comment https://forums.phpfreaks.com/topic/200463-create-variable-name-with-variable-in-it/#findComment-1051973 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.