RE: [PHP] adding a variable to a variable name

From: Date: Thu, 04 Jul 2002 10:09:09 +0000
Subject: RE: [PHP] adding a variable to a variable name
Groups: php.general 
Request: Send a blank email to php-general+get-105412@lists.php.net to get a copy of this message
> -----Original Message----- > From: Tom Beidler [mailto:tom@orbittechservices.com] > Sent: 03 July 2002 21:41 > > 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); > } [...] > I guess I could create a variable before the unset like so > > $unsetA = "level" . $i . "Name"; This does the trick: unset(${"level${i}Name"}); > but that seems cloogey. cloogey --> kludgy??? Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#105412) next »