electrix Posted September 20, 2006 Share Posted September 20, 2006 I've been googl'ing for the last 3 hours now without luck...example:--------------------$number="00";--------------------$_$number="$number"echo $_00; --------------------This should display "00" on the screen.I'm not a newbie with this so don't gimme the "echo $number should work"-speach.That's not what I want as in $number is actually a variable number taken from a user-inserted database.Easiest explanation:I want the name of the variabel ($number=) should be the same as the value (= $var;)Hope any1 understand what I mean... Link to comment https://forums.phpfreaks.com/topic/21383-probably-easy/ Share on other sites More sharing options...
wildteen88 Posted September 20, 2006 Share Posted September 20, 2006 You mean you wnat to create a variable that has the same name as its value? Ie you ahve variable holds the number 1234 and you want to create a new variable which has the name 1234 and holds the value of 1234If you do then you'll want to use curly braces:[code=php:0]$num = '1235';${'_' . $num} = $num;echo $_1235;[/code]Note if you want to the variabled to be $1234, then you cannot do that as variable names must not start with a number. Link to comment https://forums.phpfreaks.com/topic/21383-probably-easy/#findComment-95175 Share on other sites More sharing options...
electrix Posted September 20, 2006 Author Share Posted September 20, 2006 [quote author=wildteen88 link=topic=108756.msg437795#msg437795 date=1158745756]You mean you wnat to create a variable that has the same name as its value? Ie you ahve variable holds the number 1234 and you want to create a new variable which has the name 1234 and holds the value of 1234If you do then you'll want to use curly braces:[code=php:0]$num = '1235';$_{$numb} = $num;echo $_1235;[/code]Note if you want to the variabled to be $1234, then you cannot do that as variable names must not start with a number.[/quote]That I knew of (not start with a number I mean.)Still not working...What am I doing wrong?![code]$nummer="00";$_{$nummer}=$nummer;echo '"'.$_00.'"'; [/code] Link to comment https://forums.phpfreaks.com/topic/21383-probably-easy/#findComment-95178 Share on other sites More sharing options...
electrix Posted September 20, 2006 Author Share Posted September 20, 2006 [quote author=wildteen88 link=topic=108756.msg437795#msg437795 date=1158745756]You mean you wnat to create a variable that has the same name as its value? Ie you ahve variable holds the number 1234 and you want to create a new variable which has the name 1234 and holds the value of 1234If you do then you'll want to use curly braces:[code=php:0]$num = '1235';${'_' . $num} = $num;echo $_1235;[/code]Note if you want to the variabled to be $1234, then you cannot do that as variable names must not start with a number.[/quote]You just edited your post right? ;) Or else I copied extremely wrong :P Link to comment https://forums.phpfreaks.com/topic/21383-probably-easy/#findComment-95180 Share on other sites More sharing options...
wildteen88 Posted September 20, 2006 Share Posted September 20, 2006 Yeah I editted my post. I made a mistake with the code. Try the new code:[code=php:0]$num = '1235';${'_' . $num} = $num;echo $_1235;[/code] Link to comment https://forums.phpfreaks.com/topic/21383-probably-easy/#findComment-95188 Share on other sites More sharing options...
electrix Posted September 20, 2006 Author Share Posted September 20, 2006 [quote author=wildteen88 link=topic=108756.msg437808#msg437808 date=1158746489]Yeah I editted my post. I made a mistake with the code. Try the new code:[code=php:0]$num = '1235';${'_' . $num} = $num;echo $_1235;[/code][/quote]Just wanted to thank you for your help.It worked perfect! :D Link to comment https://forums.phpfreaks.com/topic/21383-probably-easy/#findComment-95240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.