interface Collection implements Countable, IteratorAggregate, JsonSerializable (View source)

Collection is the base interface which covers functionality common to all the data structures in this library. It guarantees that all structures are traversable, countable, and can be converted to json using json_encode().

Methods

int
count()

Count elements of an object

getIterator()

Retrieve an external iterator

mixed
jsonSerialize()

Specify data which should be serialized to JSON

void
clear()

Removes all values from the collection.

TValue>
copy()

Returns a shallow copy of the collection.

bool
isEmpty()

Returns whether the collection is empty.

array
toArray()

Converts the collection to an array.

Details

int count()

Count elements of an object

Return Value

int

The custom count as an integer.

The return value is cast to an integer.

Traversable getIterator()

Retrieve an external iterator

Return Value

Traversable

An instance of an object implementing Iterator or Traversable

Exceptions

Exception

mixed jsonSerialize()

Since: 5.4

Specify data which should be serialized to JSON

Return Value

mixed

data which can be serialized by json_encode, which is a value of any type other than a resource.

void clear()

Removes all values from the collection.

Return Value

void

TValue> copy()

Returns a shallow copy of the collection.

Return Value

TValue>

bool isEmpty()

Returns whether the collection is empty.

Return Value

bool

array toArray()

Converts the collection to an array.

Note: Casting to an array is not supported yet.

Return Value

array

An array containing all the values in the same order as the collection.