Re: inserting a variable into a variable

From: Date: Wed, 20 Jun 2001 20:57:13 +0000
Subject: Re: inserting a variable into a variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-54606@lists.php.net to get a copy of this message
Or, you could do... $cat = 'butch'; ${"rm_{$cat}_adt"} = 'is cool'; // This would set the variable $rm_butch_adt equal to 'is cool' -js ----- Original Message ----- From: "scott [gts]" <scott@graphictype.com> To: "php" <php-general@lists.php.net> Sent: Wednesday, June 20, 2001 8:37 AM Subject: RE: [PHP] inserting a variable into a variable > you so totally could use an assoc. array right now: > > $cat_adt = "x"; > $rm = "y"; > > $a[ $cat_adt ] = "whatever"; > $a[ "$rm"."$cat_adt" ] = "Yeah"; > > print $a['yx']; > > > save yourself a lot of trouble and dont bother with > variables-of-variables and trying to get > $rm_$cat_adt == $rm_x > > just use a hash... that's what it's there for ;) > > > > -----Original Message----- > > From: Tom Carter [mailto:subs@roundcorners.com] > > Sent: Wednesday, June 20, 2001 5:24 AM > > To: Hasan Niyaz; php-general@lists.php.net > > Subject: Re: [PHP] inserting a variable into a variable > > > > > > > I have come to a situation where i am having a variable inside another > > variable. > > > for example. > > > > > > $rm_$cat_adt > > > > PHP would read this as trying to prepend the variable $cat_adt to the > > variable $rm_ > > > > You seem to be trying to insert the variable $cat into the middle of a > > variable.. possible, but probably better to slightly rethink your naming > > strategy > > > > HTH, > > Tom > > > > > > > > The above is a variable and $cat is again another variable > > > This does not work.. > > > > > > Need some help! > > > > > > > > > Thanks, > > > Hasan > > > > > > > -- > 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 >

« previous php.general (#54606) next »