...

View Full Version : how to perform dynamic cascading references ??



PHPycho
02-25-2008, 08:33 AM
Hello forums!!
I would like to how to access nested objects
supppose i had an array

$array = array("parent_obj", "child_obj1", "child_obj2");
I would like to perform referencing as per array ie

$this->parent_obj->child_obj1->child_obj2;

I dont know how to perform dynamic cascading references.
Can anybody make a help on this.
Any help / comment/ suggestions are warmly welcome.

PHPycho
02-25-2008, 11:31 AM
Thanks i got it working by performing as:

$element = '';
foreach ($array as $obj){
$element .= '->'.$obj;
}
$element = trim($element, "->");
eval('$return = $this->'.$element.';');
return $return;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum