News Feed
Sections




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

Brandon Savage's Blog:
A Closer Look At ArrayObject
April 26, 2010 @ 10:50:33

In a new post to his blog today Brandon Savage has taken a look at the SPL ArrayObject component including how it's handled in a PHP5 OOP kind of world.

ArrayObject is an object that is designed to behave exactly like an array. If that seems confusing, don't worry, it's not. ArrayObject is an object. It follows all the rules of how objects work. But it's designed to implicitly behave like an array for all intents and purposes, including being used in a foreach loop, and accessing it's properties just like you would access the values in an array.

He includes a code snippet showing how the ArrayObject can be used and explains that, since it's an object and not an array, the "copy, not duplicate" handling applies to it. You get the best of two worlds - the ease of an array and the power of an object (plus there's some performance improvements too).

0 comments voice your opinion now!
arrayobject spl object array


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso's Blog: Checking the performance reading arrays with PHP

DZone.com: A Mockery Review

DevShed: Using PDO Objects in PHP 5 - Using the PDO extension

Byster.net: PHP5 Benchmarks

Wojciech Sznapka's Blog: Why Mockery is better than PHPUnit Mock Builder (with Symfony2)


Community Events

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


laravel5 video series language extension community laravel framework opinion library unittest interview podcast php7 security api voicesoftheelephpant release introduction version

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