News Feed
Sections




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

SitePoint PHP Blog:
Collection Classes in PHP
September 30, 2013 @ 12:21:30

On the SitePoint PHP blog a new tutorial introduces you to collection classes in PHP, replacing the more basic array with something with a bit more power.

Applications frequently have objects that contain a group of other objects, and this is a great place to make use of collections. [...] A Collection class is an OOP replacement for the traditional array data structure. Much like an array, a collection contains member elements, although these tend to be objects rather than simpler types such as strings and integers.

He mentions some of the common problems with arrays (and the data they contain) and points out that the structure a "Collection" class wraps around it can help keep things sane. He includes an example of a basic collection class that adds/gets/deletes items from an internal (private) array. He fleshes out this class with code inside those methods and a few others: keys, length and keyExists.

0 comments voice your opinion now!
collection class oop array tutorial

Link: http://www.sitepoint.com/collection-classes-in-php/

blog comments powered by Disqus

Similar Posts

Ed Finkler's Blog: Building a Tumblelog with Gimme Bar and PHP

DevShed: Using Filters in PHP 5

GoodPHPTutorials.com: Integrating the Authorize.Net AIM API with PHP

Richard Miller's Blog: Symfony2: Integrating elasticsearch

Ralph Schindler's Blog: Compiling Gearman (or anything) for Zend Server CE on Snow Leopard


Community Events





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


opinion podcast version release library framework introduction composer voicesoftheelephpant list interview artisanfiles language laravel series security symfony conference community tool

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