News Feed
Sections




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

phpRiot.com:
Using the PHP 5 Iterator interface with Smarty
March 10, 2008 @ 09:35:00

On the phpRiot blog, Quentin Zervaas has posted a quick tutorial about using the Iterator interface (part of the Standard PHP Library) together with Smarty to loop through some objects:

The PHP 5 Iterator interface is very useful for defining custom behaviour for looping over objects, however I just noticed that looping over such objects in Smarty will not work correctly. Smarty will in fact cast an object back to an array.

He includes code examples of his problem to illustrate and shows how he got around the problem - a getData() function he defined that just returns the array from the object.

2 comments voice your opinion now!
iterator interface smarty php5 spl object array


blog comments powered by Disqus

Similar Posts

Phil Bennett: Do We Need a Framework For That? Or Hurry Up PHP-FIG

Professioanl PHP Blog: Building a culture of objects in PHP

PHP.net: PHP 5.2.9-2 (Windows) released

IBM developerWorks: What's new in PHP V5.3, Part 1: Changes to the object interface

David Goodwin's Blog: Book Review: Object-Orientated Programming with PHP5 (Hasin Hayder, Packt)


Community Events





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


community install opinion symfony2 api list podcast refactor series unittest code threedevsandamaybe interview introduction laravel framework release developer language testing

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