RE: [PHP] Creating a variable name using a variable
| From: | Adam Warner | Date: | Fri, 03 Nov 2000 02:22:23 +0000 |
| Subject: | RE: [PHP] Creating a variable name using a variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-23498@lists.php.net to get a copy of this message | ||
Thanks Daniel, Matt and Kathleen,
My message only appeared to arrive to the list a couple of hours ago even
though I had received two replies by then!
So far with PHP I am fondly reminded of a Homer (Simpson) quotation:
"Is there anything a doughnut cannot do?"
Many thanks,
Adam Warner
-----Original Message-----
From: Daniel Nolan [mailto:trebz@barrysworld.com]
Sent: Friday, 3 November 2000 1:04 p.m.
To: Adam Warner
Subject: RE: [PHP] Creating a variable name using a variable
Use a variable variable
$i = 2;
$url = "url$i";
$$url will then refer to $url2 (note the 2 $$'s)
Cheers
-----Original Message-----
From: Adam Warner [mailto:adam@consulting.net.nz]
Sent: 02 November 2000 10:56
To: php-general@lists.php.net
Subject: [PHP] Creating a variable name using a variable
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?
Many thanks,
Adam
PS: To the developers of PHP many thanks. PHP is awesomely fun and powerful.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net