Re: Creating variable names from values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/8/07, Otto Wyss <otto.wyss@xxxxxxxxxx> wrote:

Satyam wrote:
>
>     $key = 'K' . $key;
>    if ($$key) {
>
> notice double dollar sign, it means, not the value of $key but the value
of
> the variable $key says.
>
Thanks, any idea where this is described in the PHP manual? Searching
for "$$" produces no results.

O. Wyss


This code fragment will produce a variable such as $yellow_7, for example,
where $aNumber is equal to 7. Then use it as any other variable.

${'yellow_' . $aNumber} = "assign something";

I've posted this example before, however, and the general consensus seems to
be to just use an array.

David

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux