|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-09-29 07:34 UTC] david dot nqd at gmail dot com
Description: ------------ SPL interfaces provide useful interfaces to let objects behave like arrays; however, there is no way for objects to use the array append syntax method without having to extend either ArrayObject or ArrayIterator. I am suggesting that a new interface called Appendable be created to allow objects to have this functionality without having to be an extension of anything. Appendable would only contain a single method, but would almost always be used with ArrayAccess, Appendable differs from the feature request (#32347) I posted earlier since it is not an extension of ArrayAccess. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 05:00:01 2025 UTC |
This is unnecessary. the offset is set to null when [] is requested <?php class test implements ArrayAccess { var $test = array(); function offsetGet($var) { return $this->test[$var]; } function offsetSet($var, $value) { if ($var === null) { $this->test[] = $value; } $this->test[$var] = $value; } function offsetExists($var) { return isset($this->test[$var]); } function offsetUnset($var) { unset($this->test[$var]); } } $a = new test; $a[] = 1; echo $a[0]; ?>