Re: Comparing form variables using a loop

From: Date: Tue, 15 Aug 2000 15:04:58 +0000
Subject: Re: Comparing form variables using a loop
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-11831@lists.php.net to get a copy of this message
I think you are going to have to use an eval statement here. since you need to take x and y and generate dynamic variable name DXXX_SHOWYYY, check out http://www.php.net/manual/function.eval.php but I think it might be somehtig like this eval("if $D" . $x . "_" . $y . "SHOW == $D" . $x+1 . "_" . $y+1 . "SHOW == $D") This should evaluate to "if $D1_3SHOW == $D2_4SHOW" when x=1 and y=3. I think if you use $x++ that will increment the counter which you may not want to do. Anyway, this may get you started (and this code is untested) it might be if eval("$D" . $x . "_" . $y . "SHOW == $D" . $x+1 . "_" . $y+1 . "SHOW == $D") { do something ... } On Tue, Aug 15, 2000 at 11:33:46AM -0400, J. Myers wrote: > Hi again, > > We're submitting a form containing a lot of variables that we would like > to compare using a loop. > > Here's what it looks like: > > Form variables: > > D0_0600SHOW = "Crow" > D1_0600SHOW = "Crow" > D0_0630SHOW = "Bat" > D1_0630SHOW = "Dog" > > > Script: > > Eg. > > Loop Start > > if $D[x]_[y]SHOW == $D[x++]_[y++]SHOW > > Loop Stop > > What it is we wish to accomplish is to have PHP reference the values of > the submitted variables > dynamically. > > > -- > 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 > -- Christopher R. Moewes-Bystrom cmoewes@moewes.com http://www.moewes.com http://www.linuxnovice.org

« previous php.general (#11831) next »