Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts

    how to perform dynamic cascading references ??

    Hello forums!!
    I would like to how to access nested objects
    supppose i had an array
    PHP Code:
    $array = array("parent_obj""child_obj1""child_obj2"); 
    I would like to perform referencing as per array ie
    PHP Code:
    $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.

  • #2
    Regular Coder
    Join Date
    Dec 2005
    Posts
    217
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks i got it working by performing as:
    PHP Code:
    $element '';
    foreach (
    $array as $obj){
        
    $element .= '->'.$obj;
    }
    $element trim($element"->");       
    eval(
    '$return = $this->'.$element.';');   
    return 
    $return


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •