Re: creating variable names on the fly
| From: | Matt McClanahan | Date: | Fri, 18 Aug 2000 18:56:14 +0000 |
| Subject: | Re: creating variable names on the fly | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12520@lists.php.net to get a copy of this message | ||
On Fri, 18 Aug 2000, Robert J. Cissell wrote:
> I have a list of variables e1, e2, e3, etc. I want to write some code
> like this:
>
> $count = 1;
> while($count <=4)
> {
> <set the value of element equal to e+count>
> print($element);
> }
>
> How would I do the first line in the while loop? Thanks.
Try
${'e' . $count} = <value>
or
${"e$count"} = <value>
Matt