News Feed
Sections




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

Ibuildings Blog:
Implementing Iterators
August 20, 2008 @ 15:02:59

On the Ibuildings blog Ruud Alberts takes a look at iterators - what they are and how they're used (including the objects the SPL makes available).

Let's kickstart this blogpost by defining what an iterator actually is. According to wikipedia, an iterator is. A collection can pretty much be anything. The most obvious sources would be arrays, but other than that, iterations can be done over database resultsets, strings, datetime intervals, directories, file content and XML listings, to name a few.

He looks at the iterator interface that comes bundled in the SPL and how you can create a custom one to loop through your own data collection. He includes an example - a colorful string iterator that "pretties up" an HTML string with various colors.

0 comments voice your opinion now!
iterator standard library spl custom color string tutorial


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso's Blog: Protect files within public folders with mod_rewrite and PHP

Zend Developer Zone: Getting Started with OpenID and PHP

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 1)

Pádraic Brady's Blog: Extending the Mapper: Stars and Planets

DevShed: Creating a Blog Application with Interpreter Classes with PHP 5


Community Events





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


threedevsandamaybe podcast list project wordpress interview community series application install introduction release developer language configure library code api laravel framework

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