Re: Question on variable variables

From: Date: Sun, 18 Nov 2001 23:39:43 +0000
Subject: Re: Question on variable variables
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-75045@lists.php.net to get a copy of this message
This would be the logical way to do it (as I see it): define('MY','pre_'); $a = "dog"; $new_var = MY.$a; $$new_var and $pre_dog are the same :) --Joe On Fri, Nov 16, 2001 at 09:47:12PM -0500, Jeff Lewis wrote: > I've a question regarding variable variable I was hoping someone could help me with: > > All the examples in the manual have the entire variable name being variable e.g. > $a = "hello" and > $$a being the same as $hello > > What I need to do, however, is append a variable portion to a constant prefix. So I have a set > of variables that are named $MYdog, $MYcat etc. and I need to do > > $a = "dog" > ${"MY$a"} being the same as $MYdog > > Can this be done, and if so - how? I can't get it to work. > > Jeff Joe Stump <joe@joestump.net> ------------------------------------------------------------------------ "How would this sentence be different if pi equaled 3?"

« previous php.general (#75045) next »