Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

Copy array in a class

Ok, as your probably aware Im new to OOP in PHP, so trying to figure things out one at a time.

Im trying to pass an array into a constructor, and copy that array into a variable in the class, so I can use it in another function, so to test:-

class protoMenu{
    private $menuArray;
    function protoMenu($arrMenu) {
        $menuArray = $arrMenu;
        $this->drawMenu();
    }

    private function drawMenu() {
        var_dump($menuArray);
    }
}

$Menu = new protoMenu(array("divContentsID" => "divMenuContents", "divMenuID" => "divMenu"));

Open in new window


Looking at array copying Im doing everything right, but its not working
ASKER CERTIFIED SOLUTION
Avatar of gr8gonzo
gr8gonzo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial