RE: [PHP] variable question...
| From: | Ford, Mike [LSS] | Date: | Tue, 16 Apr 2002 14:15:05 +0000 |
| Subject: | RE: [PHP] variable question... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-93191@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Justin Blake [mailto:justin@blaix.org]
> Sent: 16 April 2002 09:43
>
> You can use variable variable names by adding another '$'.
> so if $i == 1 and $var1 == "one", you can do this:
>
> $var_name = "var".$i;
> if($$var_name == "one") echo "Hello!";
>
> That should work,
So should:
if (${"var".$i} == "one) echo "Hello!";
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211