Comparing "dynamically named" variables

From: Date: Thu, 17 Aug 2000 15:51:23 +0000
Subject: Comparing "dynamically named" variables
Groups: php.general 
Request: Send a blank email to php-general+get-12265@lists.php.net to get a copy of this message
Hi Folks, It's us again. We are trying to compare the values of submitted form variables. Because there are 336 variables to compare, we decided on using a loop to change the variable names within an expression. Examples of our form variables are $D0_0600SHOW, $D1_0600SHOW, $D2_0600SHOW Through each increment of the loop we would like it to change the variable name to be compared. Eg. If $D0_0600SHOW == $Anothershow Loop 1 If $D1_0600SHOW == $Anothershow Loop 2 The code we're using is below. The problem that we are experiencing is the expresssion is seeing the variable name that we dynamically created as a string rather than a variable. How should we construct the variable name within the expression to have the expression see it as a variable and not as a string? --------CODE----------------------------------- $day = 0; Loop Start----------------------------------------- if ("$D".$day."_0600SHOW" == $Anothershow) { echo "We have a match"; } else { echo "NO Match"; } Loop Stop----------------------------------------- Thanks ahead of time! Jr.

« previous php.general (#12265) next »