Re: Indexing an array
| From: | Hannes Magnusson | Date: | Fri, 06 Aug 2010 15:20:47 +0000 |
| Subject: | Re: Indexing an array | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-49217@lists.php.net to get a copy of this message | ||
On Fri, Aug 6, 2010 at 16:33, mathieu.suen <mathieu.suen@easyflirt.com> wrote:
> Hi,
>
> For now you can only index an array using a scalar type or a string.
> Is there some rfc or work going on to enlarge the possibility so that it is
> possible to have some other object like:
>
I don't think it makes sense.
You can however kindof fake it:
$ php -r '$objs = new SplObjectStorage; $std = new stdclass; $std->foo
= 1; $objs->attach($std, array(1,2,3,4)); var_dump($objs[$std]);'
array(4) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
[3]=>
int(4)
}
-Hannes