Re: Creating a variable name using a variable

From: Date: Thu, 02 Nov 2000 20:06:39 +0000
Subject: Re: Creating a variable name using a variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-23448@lists.php.net to get a copy of this message
On Thu, 2 Nov 2000, Adam Warner wrote: > Hi all, > > I'm new to the list. Hopefully this is not too frequently asked... > > Now I realise I should probably be using an array. But it would be nice to > occasionally create a variable name from a variable. > > For example: > I have 3 variables $url1, $url2 and $url3. > > I have another variable $i (which takes one of the values 1, 2 or 3). > > If $i=2 is there any way I can refer to $url2 using by combining "$url" and > $i? Yes, you can say ${'url'.$i} to get $url2. http://www.php.net/manual/language.variables.variable.php Matt

« previous php.general (#23448) next »