PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
What you need to do is create a string which contains the variable name you want. e.g. I want variables named var_1, var_2 ... var_10 and then use a double $ to show that you want to create a new variable, using the contents of the variable $tmp as the name
Citizen wrote:Where would you want to do this? I've never run into a situation where having a variable variable name was the most efficient way to do something.
I'm interested in the answer to this myself, as I've not personally encountered a situation where variable variable names are of use. I can maybe see them helping in looping through a lot of values, but I'd just use an array for that.
Citizen wrote:Where would you want to do this? I've never run into a situation where having a variable variable name was the most efficient way to do something.
I'm interested in the answer to this myself, as I've not personally encountered a situation where variable variable names are of use. I can maybe see them helping in looping through a lot of values, but I'd just use an array for that.
Exactly.... I'm having trouble to see the benefit of this:
Which regardless of the processing advantage (if there was one and it was relevant), uses two lines, which you would again have to cycle through again and/or use two lines of code to retrieve it.