Re: Calling a Variable in a weird Way

From: Date: Thu, 07 Mar 2002 13:28:11 +0000
Subject: Re: Calling a Variable in a weird Way
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-87619@lists.php.net to get a copy of this message
You can do: for ($i=1; $i < 12; $i++) { $n = "state_$i"; echo $$n; } That should do what you want (if I understood what you want correctly ;) /nico "Phillip S. Baker" <phillip@freewolf.net> wrote in message news:5.1.0.14.0.20020306214751.04d02360@209.164.73.211... > I am not sure I can articulate this well. > But I will try. > > I want to combine either two variables or a variable and string to bring up > the name of a previous variable name to display the data from the first. > > So in the first part I will have a listing that will look like > <type=radio name=state_1 value=No> > <type=radio name=state_1 value=Yes> > <type=radio name=state_1 value=Maybe> > <type=radio name=state_2 value=No> > <type=radio name=state_2 value=Yes> > <type=radio name=state_2 value=Maybe> > > // Submit etc.... > > Then later I will call a for loop to try and do something like > > for ($i=1; $i < 12; $i++) { > echo state_$i; // This would print out either Yes No or Maybe. > } > > Is there a way I can do this. > I thought I heard something about how I can but I do not remember. > > Phillip >

« previous php.general (#87619) next »