Re: Variable variables
| From: | Richard Baskett | Date: | Tue, 23 Dec 2003 20:08:58 +0000 |
| Subject: | Re: Variable variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173271@lists.php.net to get a copy of this message | ||
on 12/23/03 11:04, John W. Holmes at holmes072000@charter.net wrote:
> Richard Baskett wrote:
>> Ok I am trying to create a variable from the value of a variable plus some
>> extra text tagged on the end of it.
>>
>> So for example:
>>
>> $test = '_over';
>> $$CONFIG['island'].$test = 'testing';
>
> ${$CONFIG['island'].$test} = 'testing';
>
>> echo "hawaii = $hawaii_over";
>
> Why not just use an array for all of this? Almost every time variable
> variables are used, it's a workaround to just using arrays. I don't know
> why these even exist, honestly...
I might not be sure what you mean, about using an array for all of that, but
within one line of code, it is taking care of a variable that will change
depending on the config island variable. Otherwise I would have needed to
use a switch statement, which is a whole lot more than just one variable.
But then again if your array solution would work in one line.. then I would
love to see it!
Cheers!
Rick
"It is the mark of an educated mind to be able to entertain a thought
without accepting it." - Aristotle