Re: ArrayObject - Posibillity to add key => value pair per default?
| From: | Carlos Medina | Date: | Wed, 14 Jan 2009 15:42:39 +0000 |
| Subject: | Re: ArrayObject - Posibillity to add key => value pair per default? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286315@lists.php.net to get a copy of this message | ||
Edmund Hertle schrieb:
Hey, I've just discovered the ArrayObject class, but it seems to not be well documented, so here is my problem: You can use ArrayObject::append() to add a new value to the array, but is there also a method to add a new key and value? And I know that I could extend the class and write my own method but isn't this quite a base method for arrays in php? So maybe I just missed a obvious point? Quick example: Without ArrayObject: 1. $array[] = $value 2. $array[$key] = $value With ArrayObject: 1. $arrayObject->append($value) 2. ??? -eddy Hi Eddy,use offsetSet( key, data) to do this. You can implements the Interface or extend from the Class to extend the functionality (think interceptors __SET and __GET) Regards Carlos Medina