News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sean Coates' Blog:
A Case of Mistaken Iterator
July 29, 2010 @ 12:48:51

In a new post to his blog today Sean Coates talks about some of his work with Iterators in PHP and how, despite a bad example in the manual, he solved his issue (and updated the PHP manual too).

In the back end, we have models that connect to CouchDB. These models implement the Iterator pattern to allow easy traversal of a record's keys. [...] Little did I realize that this implementation is very broken. [...] Over the past few years, I've implemented many iterators in this way, using PHP's implicit array manipulation functions (reset(), current(), key(), next()).
He points out some issues with how PHP handles array index tracking and how, in the previous PHP manual example, it incorrectly checked for "false" against the current array value. His updated version doesn't have this issue. You can see it here.

0 comments voice your opinion now!
iterator mistake manual update


blog comments powered by Disqus

Similar Posts

DevShed: The Active Record Pattern, Concluded

Ilia Alshanetsky's Blog: PHP 5.2 will feature libSQlite 3.3.7

PHPWomen.org: Filter and PHP 5.2

Community News: Joomla! Major Security Update - v1.0.10

The Nerdery: Is my code compatible with PHP 5.4 or 5.5?


Community Events





Don't see your event here?
Let us know!


symfony introduction release opinion interview community version podcast voicesoftheelephpant composer application update language tool laravel package library security framework series

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework