Re: [PHP] Converting String to Variable
At 17:09 03.03.2001, Randy Johnson said: [snip] Is there anyway to convert a string to a variable example $str="monday"; I would like to then do this: $monday="blah"; [snip] RTFM ;- $$str = "blah"; print $monday; ...ebird O Ernest E. Vogelsinger (\)http://www.1-at-web.at/ ^ ICQ# 13394035 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Converting String to Variable
it may look weird but that is the way it needs to be done. here is a better example $str=myfunct() this returns monday then i want the monday to turn into this $monday so i can do this $monday="BlaH"; thanks randy -Original Message- From: Ernest E Vogelsinger [mailto:[EMAIL PROTECTED]] Sent: Saturday, March 03, 2001 11:35 AM To: Randy Johnson Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Converting String to Variable At 17:09 03.03.2001, Randy Johnson said: [snip] Is there anyway to convert a string to a variable example $str="monday"; I would like to then do this: $monday="blah"; [snip] RTFM ;- $$str = "blah"; print $monday; ...ebird O Ernest E. Vogelsinger (\)http://www.1-at-web.at/ ^ ICQ# 13394035 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Converting String to Variable
Here's my question: why do you want to do this, and is there a better way to do this, say a hash list or something? BTW, isn't monday defined as a constant that always equals "blah!" It always has for me. -Original Message- From: Randy Johnson [mailto:[EMAIL PROTECTED]] Sent: Saturday, March 03, 2001 9:44 AM To: Ernest E Vogelsinger; Randy Johnson Cc: [EMAIL PROTECTED] Subject: RE: [PHP] Converting String to Variable it may look weird but that is the way it needs to be done. here is a better example $str=myfunct() this returns monday then i want the monday to turn into this $monday so i can do this $monday="BlaH"; thanks randy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Converting String to Variable
On 3 Mar 2001 08:02:16 -0800, Randy Johnson [EMAIL PROTECTED] wrote: Is there anyway to convert a string to a variable example $str="monday"; I would like to then do this: $monday="blah"; extract() does something like that for arrays. There's no way to write the code the way you have it, but you could use this syntax, which is equivalent: $$str = "blah"; $GLOBALS[$str] = "blah"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]