Re: Object member variable names

From: Date: Mon, 26 Aug 2002 23:10:01 +0000
Subject: Re: Object member variable names
Groups: php.general 
Request: Send a blank email to php-general+get-114196@lists.php.net to get a copy of this message
>Hi, > >I've got a little problem with variable naming of object members. Here is my >situation: I've got a website form, whoms contents will be saved in a MySQL >table with two fields: name and value. The name could be anything like >"bla->test", "array[3]->test[4]->name"... > >Now I have a php script reading out the MySQL table, and I want to assign >the variables like this: >$object->$name, i.e. >$object->bla->test = "some value"; >$object->array[3]->tes[4]->name = "some other value"; etc. > >Using $object->$name doesn't work, as this seems to ignore submembers and >arrays. >Any ideas how to solve my problem? You might try: $object->{$name} = "some value"; If all else fails, you could probably dink around with http://php.net/eval and get what you want. -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#114196) next »