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

Methods

__construct(int $size = 0)

Constructs a new fixed array

int<0, max>
count()

Returns the size of the array

TValue[]
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

TValue
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

TValue
current()

Return current array entry

TKey|null
key()

Return current array index

void
next()

Move to next entry

bool
valid()

Check whether the array contains more elements

__wakeup()

No description

array
__serialize()

No description

void
__unserialize(array $data)

No description

TValue>|TValue[]
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<0, max> count()

Returns the size of the array

Return Value

int<0, max>

The custom count as an integer.

The return value is cast to an integer.

TValue[] toArray()

Returns a PHP array from the fixed array

Return Value

TValue[]

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.

TValue offsetGet(int $index)

Returns the value at the specified index

Parameters

int $index

The index with the value.

Return Value

TValue

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.

TValue current()

Return current array entry

Return Value

TValue

Can return any type.

TKey|null key()

Return current array index

Return Value

TKey|null

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.

__wakeup()

No description

array __serialize()

No description

Return Value

array

void __unserialize(array $data)

No description

Parameters

array $data

Return Value

void

TValue>|TValue[] getIterator()

Since: 8.0

No description

Return Value

TValue>|TValue[]

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.