Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable variables and object member variables...

Status
Not open for further replies.

gultekin

Programmer
Joined
Jun 9, 2003
Messages
2
Location
GB
can anyone enlighting me on how i can use variable variables to access object member variables?



PHP:--------------------------------------------------------------------------------
while($element = each($row))
{
//want to be able to assign array values to corresponding
//member variables based on associative array keys
//something like this....
$varname = "this->".$element["key"];
$$varname = $element["value"];
}

--------------------------------------------------------------------------------


any suggestions?

tekin
 
hi.
found out how to do it.
squigly brackets can be used to use variables to access object member variables like so::

while($element = each($row))
$this->{$element["key"]} = $element["value"];

thanks anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top