표준 PHP 라이브러리(SPL) ArrayIterator::rewind
(PHP 5, PHP 7, PHP 8)
ArrayIterator::rewind — 배열을 처음으로 되감기
설명
public ArrayIterator::rewind(): void
반복자를 처음으로 되감습니다.
매개변수
이 함수에는 매개변수가 없습니다.
반환 값
값이 반환되지 않습니다.
Examples
예제 #1 ArrayIterator::rewind() 예제
<?php
$arrayobject = new ArrayObject();
$arrayobject[] = 'zero';
$arrayobject[] = 'one';
$arrayobject[] = 'two';
$iterator = $arrayobject->getIterator();
$iterator->next();
echo $iterator->key(); //1
$iterator->rewind(); //rewinding to the beginning
echo $iterator->key(); //0
?>