SplFixedArray クラスはじめにSplFixedArray クラスは配列の主要な機能を提供します。 SplFixedArray と通常の PHP の配列との主な違いは、 SplFixedArray は手動でリサイズしなければならないことと、 整数値で指定した範囲内の添字しか使用できないところです。 これにより、標準の array よりメモリ消費が少なくて済みます。 クラス概要
SplFixedArray
implements
IteratorAggregate
ArrayAccess
Countable
JsonSerializable
/* メソッド */
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()
#[\Deprecated]
public void __wakeup()
変更履歴
例
例1 SplFixedArray の使用例 上の例の出力は以下となります。 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
|