Developer's Guide :: List Arrays

From Delphi for PHP Documentation Wiki

Jump to: navigation, search

In Delphi for Win32, there is a class named TList, in VCL for PHP, the equivalent is called Collection, which is a class that provides a way to handle a list of "things", as they can contain almost anything. Collections are wrappers to PHP arrays, so in some cases, a pure PHP array will be the best option for speed sake.

In PHP, arrays are really powerful, and there is a lot of built-in functions to handle arrays, so Collection class has been provided to ease the path to PHP, but in most cases, an array is enough.

Collections in the VCL for PHP provide the following methods:

 
integer add( object $item)
// Add an item to the list
// object $item Object to add to the list
 
void clear( )
// Clears the list
 
integer count( )
// Return the number of items in the list
 
void delete( integer $index)
// Delete an item from the list by its index
// integer $index Index of the item to delete
 
void indexof( object $item)
// Finds an item into the list
// object $item Item to find
 
object last( )
// Return the last element from the collection
 
void remove( object $item)
// Remove an item from the list
// object $item Item to delete from the list
 

To get in touch with PHP arrays, follow this link: Array Functions

Personal tools