>
> On 16 Dec 2014, at 10:52, Andrea Faulds <[email protected]> wrote:
>
> Exactly. If I were to do this:
>
> <?php
> class Foo {
> public $foo;
> function __construct($foo) {
> $this->foo = $foo;
> }
> function __toKey() {
> return $this->foo;
> }
> }
> $arr = [];
> $arr[] = new Foo(1);
> var_dump($arr);
>
> I would get this:
>
> array(1) {
> [0]=>
> int(1)
> }
Er, a correction… the example should’ve been something like this:
$arr = [];
$arr[new Foo(1)] = NULL;
Producing this:
array(1) {
[1]=>
NULL
}
Obviously, it has no effect on values, only keys, sorry!
--
Andrea Faulds
http://ajf.me/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php