guilhermebla...@gmail.com wrote on 17/12/2014 12:43:
Answering the question of Christopher Becker. It is not possible to
traverse and get your desired elements.
How would you achieve a foreach by key (returning object) without having to
store a separate list and track by hash or through an interface?

SplObjectStorage supports that mechanism, although it's not the most intuitive design. See this comment in the manual: http://php.net/manual/en/class.splobjectstorage.php#114059

As others have pointed out, this proposal does *not* support that usage, because the hash function is one-way, and you cannot get back the object based only on the calculated key. All it does is reduce the boilerplate needed for hashing an object to produce a suitable array key.


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to