class SplFixedArray implements Iterator, ArrayAccess, Countable, IteratorAggregate, JsonSerializable (View source)

Methods

__construct(int $size = 0)

Constructs a new fixed array

int
count()

Returns the size of the array

array
toArray()

Returns a PHP array from the fixed array

static SplFixedArray
fromArray(array $array, bool $preserveKeys = true)

Import a PHP array in a SplFixedArray instance

int
getSize()

Gets the size of the array

bool
setSize(int $size)

Change the size of an array

bool
offsetExists(int $index)

Returns whether the requested index exists

mixed
offsetGet(int $index)

Returns the value at the specified index

void
offsetSet(int $index, TValue $value)

Sets a new value at a specified index

void
offsetUnset(int $index)

Unsets the value at the specified $index

void
rewind()

Rewind iterator back to the start

mixed
current()

Return current array entry

mixed
key()

Return current array index

void
next()

Move to next entry

bool
valid()

Check whether the array contains more elements

void
__wakeup()

No description

array
__serialize()

No description

void
__unserialize(array $data)

No description

getIterator()

No description

mixed
jsonSerialize()

Specify data which should be serialized to JSON

Details

__construct(int $size = 0)

Constructs a new fixed array

Parameters

int $size [optional]

int count()

Returns the size of the array

Return Value

int

The custom count as an integer.

The return value is cast to an integer.

array toArray()

Returns a PHP array from the fixed array

Return Value

array

a PHP array, similar to the fixed array.

static SplFixedArray fromArray(array $array, bool $preserveKeys = true)

Import a PHP array in a SplFixedArray instance

Parameters

array $array

The array to import.

bool $preserveKeys

[optional]

Try to save the numeric indexes used in the original array.

Return Value

SplFixedArray

an instance of SplFixedArray containing the array content.

int getSize()

Gets the size of the array

Return Value

int

the size of the array, as an integer.

bool setSize(int $size)

Change the size of an array

Parameters

int $size

The new array size.

Return Value

bool

bool offsetExists(int $index)

Returns whether the requested index exists

Parameters

int $index

The index being checked.

Return Value

bool

true on success or false on failure.

The return value will be casted to boolean if non-boolean was returned.

mixed offsetGet(int $index)

Returns the value at the specified index

Parameters

int $index

The index with the value.

Return Value

mixed

Can return all value types.

void offsetSet(int $index, TValue $value)

Sets a new value at a specified index

Parameters

int $index

The index being set.

TValue $value

The value to set.

Return Value

void

void offsetUnset(int $index)

Unsets the value at the specified $index

Parameters

int $index

The index being unset.

Return Value

void

void rewind()

Rewind iterator back to the start

Return Value

void

Any returned value is ignored.

mixed current()

Return current array entry

Return Value

mixed

Can return any type.

mixed key()

Return current array index

Return Value

mixed

TKey on success, or null on failure.

void next()

Move to next entry

Return Value

void

Any returned value is ignored.

bool valid()

Check whether the array contains more elements

Return Value

bool

The return value will be casted to boolean and then evaluated. Returns true on success or false on failure.

void __wakeup()

No description

Return Value

void

array __serialize()

No description

Return Value

array

void __unserialize(array $data)

No description

Parameters

array $data

Return Value

void

Traversable getIterator()

Since: 8.0

No description

Return Value

Traversable

An instance of an object implementing Iterator or Traversable

mixed jsonSerialize()

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.