Re: Indexing an array
| From: | Johannes Schlüter | Date: | Mon, 09 Aug 2010 12:36:50 +0000 |
| Subject: | Re: Indexing an array | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-49227@lists.php.net to get a copy of this message | ||
On Mon, 2010-08-09 at 13:47 +0200, mathieu.suen wrote:
> > outputs ...
> >
> > Array
> > (
> > [1365443950] => First
> > [1235256771] => Second
> > [520059180] => Third
> > [486985268] => Fourth
> > )
>
> Well that is not the expected behavior since if you call array_keys you
> won't get the object.
Well, "arrays" are implemented as hash tables, hash tables work by
generating a hash to identify a value. Changing this is a big change
(rewrite everything accessing array keys) and you can always do
something like
$array = array(
spl_object_hash($object1) => array('object' => $object1, 'data' => /*
...*/),
spl_object_hash($object2) => array('object' => $object2, 'data' => /*
...*/),
/*...*/
);
The only thing I can imagine is that we add support for objects
implementing ArrayAccess and Traversable (Iterator) on more places.
johannes