Re: {Spam?} Re: [PHP] Anyone using SPL Iterators?
| From: | Curt Zirzow | Date: | Wed, 22 Sep 2004 02:42:17 +0000 |
| Subject: | Re: {Spam?} Re: [PHP] Anyone using SPL Iterators? | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-197504@lists.php.net to get a copy of this message | ||
* Thus wrote Curt Zirzow:
> * Thus wrote John Holmes:
> >
> > A later example implements ArrayAccess and IteratorAggregate and then
> > says you can use count($A), but it doesn't work for my tests. It always
> > returns 1.
>
> That example i think is minor mistake. As noted in the example
> above you have to call pass ->getIterator() to count(). count()
> doesn't detect if the object if getIterator is present, its just
> returns 1 since $A isn't an array.
>
> BUT.. this works:
>
> echo count( (array)$A );
btw, the casting of the object isn't calling getIterator(), but
simply returns an array of all the public members of the object.
Curt
--
The above comments may offend you. flame at will.