Namespaces

Classes

Interfaces

Interface Collection

The missing (SPL) Collection/Array/OrderedMap interface.

A Collection resembles the nature of a regular PHP array. That is, it is
essentially an ordered map that can also be used like a list.

A Collection has an internal iterator just like a PHP array. In addition, a
Collection can be iterated with external iterators, which is preferrable. To use
an external iterator simply use the foreach language construct to iterate over
the collection (which calls IteratorAggregate::getIterator() internally) or explicitly
retrieve an iterator though IteratorAggregate::getIterator() which can then be used to
iterate over the collection. You can not rely on the internal iterator of the
collection being at a certain position unless you explicitly positioned it
before. Prefer iteration with external iterators.

Parameters

Returns

Partitions this collection in two collections according to a predicate. Keys
are preserved in the resulting collections.

Partitions this collection in two collections according to a predicate. Keys
are preserved in the resulting collections.

Parameters

$p

The predicate on which to partition.

Returns

arrayAn array with two elements. The first element contains the collection of
elements where the predicate returned TRUE, the second element contains the
collection of elements where the predicate returned FALSE.

Parameters

Returns

Extract a slice of $length elements starting at position $offset from the
Collection.

Extract a slice of $length elements starting at position $offset from the
Collection.

If $length is null it returns all elements from $offset to the end of the
Collection. Keys have to be preserved by this method. Calling this method will
only return the selected slice and NOT change the elements contained in the
collection slice is called on.