On 31-12-2009 at 15:23:20 Iván Montes <drsl...@pollinimini.net> wrote:

I've put together a very simple chunk iterator [1] which works with arrays, traversables and iterators. There is also an example tales modifier.

Perhaps it could even be added to the standard PHPTAL code base?

[1] http://gist.github.com/266759

Thank you.

That's a good start, but doesn't avoid creation of arrays yet. What I actually had in mind was pair of iterators (one for rows like you've created, another for each row) that doesn't create PHP array at any point, just passes calls to the innermost iterator. That would ensure constant memory usage (rather than 1/number_of_columns) on arbitrarily large iterations, which I think is the major reason to use iterators instead of (presumably faster) array_chunk(iterator_to_array()).

--
regards, Kornel

_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to