demon_athens Posted July 27, 2007 Share Posted July 27, 2007 Hi there, I want to create some variables that equal something in a loop. How can I have a variable name created by other variable? For example ( this is not working but you will understand what I am trying to do) $i=1; $mitsos.$i = "test"; echo "<br>".$mitsos1; This should be very easy, but I am really stuck here. Quote Link to comment Share on other sites More sharing options...
demon_athens Posted July 27, 2007 Author Share Posted July 27, 2007 hm..very damn question. An array should be fine. never mind thanks! Quote Link to comment Share on other sites More sharing options...
Crow Posted July 27, 2007 Share Posted July 27, 2007 I know you said that your question was answered, but here's the correct answer below (for future reference): For this you want to use curley-braces to evaluate the variables before creating a new variable: <?php $i = 1; ${mitsos . $i} = 'test'; echo '<br>' . $mitsos1; ?> Hope this helps. Steve Quote Link to comment Share on other sites More sharing options...
ignace Posted July 27, 2007 Share Posted July 27, 2007 this manner is called "variable variables" just so you know 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.