SplObjectStorage::next

次のエントリに移動する

説明

public void SplObjectStorage::next()

イテレータを、ストレージ内の次のオブジェクトに移動します。

パラメータ

この関数にはパラメータはありません。

戻り値

値を返しません。

例1 SplObjectStorage::next の例

<?php
$s 
= new SplObjectStorage();

$o1 = new stdClass;
$o2 = new stdClass;

$s->attach($o1"d1");
$s->attach($o2"d2");

$s->rewind();
while(
$s->valid()) {
    
$index  $s->key();
    
$object $s->current(); // current($s) と同等

    
var_dump($index);
    
var_dump($object);
    
$s->next();
}
?>

上の例の出力は、 たとえば以下のようになります。

int(0)
object(stdClass)#2 (0) {
}
int(1)
object(stdClass)#3 (0) {
}

参考

  • SPLObjectStorage::rewind