SplFixedArray
class SplFixedArray implements Iterator, ArrayAccess, Countable, IteratorAggregate, JsonSerializable (View source)
The SplFixedArray class provides the main functionalities of array. The main difference between a SplFixedArray and a normal PHP array is that the SplFixedArray must be resized manually and allows only integers within the range as indexes. The advantage is that it uses less memory than a standard array.
Methods
Constructs a new fixed array
Returns the size of the array
Returns a PHP array from the fixed array
Import a PHP array in a SplFixedArray instance
Gets the size of the array
Change the size of an array
Returns whether the requested index exists
Returns the value at the specified index
Sets a new value at a specified index
Unsets the value at the specified $index
Rewind iterator back to the start
Return current array entry
Return current array index
Move to next entry
Check whether the array contains more elements
Reinitialises the array after being unserialised
Serializes the SplFixedArray object
Deserializes the data parameter into an SplFixedArray object
Retrieve the iterator to go through the array
Returns a representation that can be converted to JSON
Details
__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()
Reinitialises the array after being unserialised
array
__serialize()
Serializes the SplFixedArray object
void
__unserialize(array $data)
Deserializes the data parameter into an SplFixedArray object
Traversable
getIterator()
Retrieve the iterator to go through the array
Returns the iterator to go through the array.
mixed
jsonSerialize()
Returns a representation that can be converted to JSON
Serializes the array to a value that can be serialized natively by json_encode.