Re: Comparing "dynamically named" variables
| From: | Robin Vickery | Date: | Thu, 17 Aug 2000 16:50:41 +0000 |
| Subject: | Re: Comparing "dynamically named" variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12284@lists.php.net to get a copy of this message | ||
jr@mediastop.com ("J. Myers") writes:
> Hi Folks, It's us again.
> 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)
Try this:
if ( ${"$D".$day."_0600SHOW"} == $Anothershow )
> {
> echo "We have a match";
> }
> else
> {
> echo "NO Match";
> }
>
> Loop Stop-----------------------------------------
>
--
Robin Vickery...............................................
Planet-Three, 3A West Point, Warple Way, London, W3 0RG, UK
Email: robin@planet-three.net Phone: +44 (0)794 670 6395