Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Copy array in a class

Posted on 2013-01-17
1
Medium Priority
?
261 Views
Last Modified: 2013-01-17
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
0
Comment
Question by:tonelm54
1 Comment
 
LVL 35

Accepted Solution

by:
gr8gonzo earned 2000 total points
ID: 38789442
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question