Re: adding a variable to a variable name

From: Date: Wed, 03 Jul 2002 21:04:58 +0000
Subject: Re: adding a variable to a variable name
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-105292@lists.php.net to get a copy of this message
check for eval function -- Sincerely, val petruchek "Tom Beidler" <tom@orbittechservices.com> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:B948AF7A.3F48%tom@orbittechservices.com... > I'm wondering if this can be done, and if so, what's the proper way to do > it. > > For the current issue I'm trying to unset some variables with common names > and I would like to step through them with a loop. Here's where I'm at to > give you an idea but the code doesn't work. > > for ($i = 2; $i <= 4; $i++) { > unset($level$iName); > unset($level$iUrl); > } > > so the code unsets > > unset($level2Name); > unset($level2Url); > unset($level3Name); > unset($level3Url); > unset($level4Name); > unset($level4Url); > > I guess I could create a variable before the unset like so > > $unsetA = "level" . $i . "Name"; > > but that seems cloogey. > > Thanks, > Tom >

« previous php.general (#105292) next »