RE: [PHP] Calling a Variable in a weird Way

From: Date: Thu, 07 Mar 2002 05:54:05 +0000
Subject: RE: [PHP] Calling a Variable in a weird Way
Groups: php.general 
Request: Send a blank email to php-general+get-87583@lists.php.net to get a copy of this message
> for ($i=1; $i < 12; $i++) { > echo state_$i; // This would print out either Yes No or Maybe. > } What you actually want is: for ($i=1; $i < 12; $i++) { $mystate = "state_".$i; echo $$mystate; // This would print out either Yes No or Maybe. } $$X tells PPH to use the value contained in the variable named $X. Jason

« previous php.general (#87583) next »