RE: [PHP] Variable Variables Help Please

From: Date: Thu, 31 Aug 2000 08:00:19 +0000
Subject: RE: [PHP] Variable Variables Help Please
Groups: php.general 
Request: Send a blank email to php-general+get-14527@lists.php.net to get a copy of this message
> Hello. I have three variables. The first one is $times. That is the > number of times my for loop has executed. The second variable is $value_1. > This is the value of a text box, let's say Alpha. My third variable is > $value_2. This is the value of my second text box, let's say Beta. I would > like to call something like $value_$times and have it go to be Alpha on the > first time of the loop and Beta on the second time of the loop. > $value_$times doesn't work. Does anyone know what would > work? Thank you in advance for all of your help. Create a temp variable which is the _name_ of the variable you want to access. ie, say I wanted to access "time_1", it'd be: $tempvar = "time_1"; // and thus, $tempvar = "value_".$times; Then access: $$tempvar; Jason

« previous php.general (#14527) next »