The SplFixedArray classIntroductionThe 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. Class synopsis
SplFixedArray
implements
IteratorAggregate
ArrayAccess
Countable
JsonSerializable
/* Methods */
public __construct(int
$size = 0)public int count()
public mixed current()
public static SplFixedArray fromArray(array
$array , bool $preserveKeys = true )public Iterator getIterator()
public int getSize()
public array jsonSerialize()
public int key()
public void next()
public bool offsetExists(int
$index )public mixed offsetGet(int
$index )public void offsetSet(int
$index , mixed $value )public void offsetUnset(int
$index )public void rewind()
public array __serialize()
public true setSize(int
$size )public array toArray()
public void __unserialize(array
$data )public bool valid()
public void __wakeup()
Changelog
Examples
Example #1 SplFixedArray usage example
The above example will output: NULL int(2) string(3) "foo" RuntimeException: Index invalid or out of range RuntimeException: Index invalid or out of range RuntimeException: Index invalid or out of range
|