Kevin Waterson wrote:

Is anyone using SPL iterators out there? Any examples you'd like to share that you find useful? Iterating through databases or large files, etc? Just curious what people are using this for before I write some stuff myself. :)


I am using them in the current script I am writing (thumbnail generator).
Basically just getting a directory listing and iterating through the array
of filenames and if its an image file, generate a thumbnail. This is my
first foray into them.

Sounds interesting. The article seemed to imply there was a way to do this recursively using foreach and a "flattened" version of the directory and files. Is this what you're doing or are you just going through a single directory?


I have found a bug in the array iterator through using count(). This
causes a segfault. Have been poking through the source to find the problem, but no joy yet.


This sort of thing causes a segfault. Assume ArrayReloded implements iterator
as in the tutorial you pointed to.
// Create iterator object
$critters = new ArrayReloaded(array ('dingo','wombat','koala',));

// echo the size of the array
echo $critters->count();

Hmm... interesting. Do you have to implement count()? It's not required by the "iterator" interface.


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.

--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to