Re: Comparing "dynamically named" variables
| From: | Web Master | Date: | Thu, 17 Aug 2000 14:58:19 +0000 |
| Subject: | Re: Comparing "dynamically named" variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12270@lists.php.net to get a copy of this message | ||
Just a thought, why do you want to use dynamically created variables, when
you can use dynamic arrays in the form and pass it back to match for the
values?
"J. Myers" wrote:
> 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.
>
> --
> 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