RE: [PHP] A variable with a variable

From: Date: Thu, 10 Jan 2002 23:25:17 +0000
Subject: RE: [PHP] A variable with a variable
Groups: php.general 
Request: Send a blank email to php-general+get-80110@lists.php.net to get a copy of this message
you'll be wanting "pointers" eg $Var_1_Stat = "hello world"; $Num = 1; $var_name = "Var_${Num}_Stat"; // set up the actual var name $Var_Call = $$var_name; // now reference the actual var echo $Var_Call; // should by "hello world" ... :) -----Original Message----- From: Yoed [mailto:yoed@zarcrom.com] Sent: Friday, January 11, 2002 10:01 AM To: php-general@lists.php.net Subject: [PHP] A variable with a variable I never really found the trick to this one yet, and wanted to see what you guys say is the best methods to call a variable that needs a variable. Say I have variables called $Var_1_Stat, $Var_2_Stat, and $Var_3_Stat and I have a variable called $Nums thats value is either 1, 2, or 3. How then would I go about calling $Var_Call=$Var_$Num_Stat ? Or $Var_Call="$Var_$Num_State".... hmm not hat wouldn't work? So what do you guys suggest? No if statements... since I want to know a way that can be used if I have more then just 3 or a limited ammount of varaibles. Thank you for your time, Yoed -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#80110) next »