Re: Array within a Class?
| From: | Michael Sims | Date: | Sat, 05 Jan 2002 23:55:56 +0000 |
| Subject: | Re: Array within a Class? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-11317@lists.php.net to get a copy of this message | ||
At 03:04 PM 1/5/2002 -0800, Chris Hall wrote:
Just a quicky -- I have yet to see anyone define an array within a class, yet if it is possible, would i be able to access that array with $this->array["variable"];?I've designed a class that has a method that RETURNS an array, but it sounds like you want to define one of the properties of your class as an array, i.e.: class testObject {
var $testarray = array("firstindex" => "firstvalue",
"secondindex" => "secondvalue");
...} I haven't personally done this, but I can't see why it wouldn't be possible. Then if you wanted to access it inside a method you should be able to the way you have described, like:
function testMethod () {
return $this->testarray["firstindex"];
}
Should work....why don't you give it a shot and see what happens? :)