Re: Creating variable names from values

From: Date: Thu, 08 Mar 2007 19:32:47 +0000
Subject: Re: Creating variable names from values
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-250116@lists.php.net to get a copy of this message
On 3/8/07, Otto Wyss <otto.wyss@orpatec.ch> 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

« previous php.general (#250116) next »