Re: PHP5 + SPL - Creating an object as an array.
| From: | Yotam Ofek | Date: | Thu, 03 Feb 2005 17:17:24 +0000 |
| Subject: | Re: PHP5 + SPL - Creating an object as an array. | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-208004@lists.php.net to get a copy of this message | ||
Jason Barnett wrote:
Yotam Ofek wrote:Seems that it you were right about ArrayIterator and ArrayObject. If anyone needs further help with this, email me.I would like to create an object like this: <?php class TestClass {Yes, this is exactly what the SPL is for. Actually the exact classes you will want to check out are called ArrayIterator and ArrayObject. Although I don't know for certain about making $some_array private... it *might* need to be public. No promises either way on that one, just look out for it ;)private $some_array; public $just; public $some; public $public; public $vars;} ?> Is it possible, through SPL, to make the class accessible as "$testclass['array_key']", which will return the value for the key'array_key' from "$some_array"? Not only that, but I want the class to be accessable as "$testclass->just" aswell! Is that possible? Examples are welcome. Thanks in advance, Yotam Ofek!Thanks.