PHP 8.5.0 Beta 3 available for testing

ArrayIterator::rewind

(PHP 5, PHP 7, PHP 8)

ArrayIterator::rewind โ€” Rewind array back to the start

่ฏดๆ˜Ž

public ArrayIterator::rewind(): void

This rewinds the iterator to the beginning.

ๅ‚ๆ•ฐ

ๆญคๅ‡ฝๆ•ฐๆฒกๆœ‰ๅ‚ๆ•ฐใ€‚

่ฟ”ๅ›žๅ€ผ

ๆฒกๆœ‰่ฟ”ๅ›žๅ€ผใ€‚

็คบไพ‹

็คบไพ‹ #1 ArrayIterator::rewind() example

<?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
?>

๏ผ‹ๆทปๅŠ ๅค‡ๆณจ

็”จๆˆท่ดก็Œฎ็š„ๅค‡ๆณจ

ๆญค้กต้ขๅฐšๆ— ็”จๆˆท่ดก็Œฎ็š„ๅค‡ๆณจใ€‚
To Top