RE: [PHP] Purpose of $$var ?????

From: Date: Tue, 16 Jul 2002 14:15:26 +0000
Subject: RE: [PHP] Purpose of $$var ?????
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-107871@lists.php.net to get a copy of this message
variable variable... right up there with array array basically what you are saying is resolve $var, then find out what that variable holds example; assume your $counter is currently at 5 $var = "v".$counter."_high_indiv"; would mean that $var= "v5_high_indiv" assuming that v5_high_indiv is dynamically assigned somewhere as a variable $$var is the value of $v5_high_indiv make sense? variable variables are especially good in loops... for example, if you have variables called $user1, $user2, $user3.... to print out all the variables would require one line per variable (and alot of typing). using variable variables you could print out the value of all users by looping it for($i=1;$i<100;$i++){ $user="user".$i; echo $$user; } Dave >-----Original Message----- >From: Scott Fletcher [mailto:scott@abcoa.com] >Sent: Tuesday, July 16, 2002 9:54 AM >To: php-general@lists.php.net >Subject: [PHP] Purpose of $$var ????? > > >The script was working great before PHP 4.2.x and not after that. So, I >looked through the code and came upon this variable, "$$var". I have no >idea what the purpose of the double "$" is for a variable. Anyone know? > >--clip-- > $var = "v".$counter."_high_indiv"; > $val3 = $$var; >--clip > >Thanks, > FletchSOD > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#107871) next »