abstract class AbstractArray implements ArrayInterface (View source)

This class provides an implementation of the ArrayInterface, to minimize the effort required to implement this interface

Properties

protected array $data

Methods

__construct(array $data = [])

Constructs a new array object

getIterator()

Returns a new iterator from this array

bool
offsetExists(mixed $offset)

Checks whether the specified offset exists in the array

mixed
offsetGet(mixed $offset)

Returns the value stored at the specified offset in the array

offsetSet(mixed $offset, mixed $value)

Sets the specified offset in the map with the given value

offsetUnset(mixed $offset)

Removes the specified offset and its value from the map

string
serialize()

Converts this map object to a string when the object is serialized with serialize()

unserialize(string $serialized)

Re-constructs the object from its serialized form

int
count()

Returns the number of elements contained in this array

void
clear()

Remove all the elements from this array object

toArray()

Returns a native PHP array containing all of the elements in this array object

bool
isEmpty()

Returns true if this array object contains no elements

Details

__construct(array $data = [])

Constructs a new array object

Parameters

array $data

ArrayIterator getIterator()

Returns a new iterator from this array

Return Value

ArrayIterator

bool offsetExists(mixed $offset)

Checks whether the specified offset exists in the array

Parameters

mixed $offset

Return Value

bool

mixed offsetGet(mixed $offset)

Returns the value stored at the specified offset in the array

Parameters

mixed $offset

Return Value

mixed

offsetSet(mixed $offset, mixed $value)

Sets the specified offset in the map with the given value

Parameters

mixed $offset
mixed $value

Exceptions

InvalidArgumentException

offsetUnset(mixed $offset)

Removes the specified offset and its value from the map

Parameters

mixed $offset

string serialize()

Converts this map object to a string when the object is serialized with serialize()

Return Value

string

unserialize(string $serialized)

Re-constructs the object from its serialized form

Parameters

string $serialized

int count()

Returns the number of elements contained in this array

Return Value

int

void clear()

Remove all the elements from this array object

Return Value

void

toArray()

Returns a native PHP array containing all of the elements in this array object

bool isEmpty()

Returns true if this array object contains no elements

Return Value

bool