PHP 8.4.2 Released!

SplFixedArray::rewind

(PHP 5 >= 5.3.0, PHP 7)

SplFixedArray::rewindRewind iterator back to the start

说明

public SplFixedArray::rewind(): void

Rewinds the iterator to the beginning.

参数

此函数没有参数。

返回值

没有返回值。

添加备注

用户贡献的备注 1 note

up
0
kishor10d at gmail dot com
5 years ago
<?php

/**
* Example : rewind();
*/

$arr = new SplFixedArray(5);

$arr[1] = 2;
$arr[4] = "foo";

$a = $arr->key();
var_dump($a);
echo
"<br>";

$arr->next();
$a = $arr->key();
var_dump($a);
echo
"<br>";

$arr->next();
$a = $arr->key();
var_dump($a);
echo
"<br>";

$arr->rewind();
$a = $arr->key();
var_dump($a);
echo
"<br>";
?>

The above example will output:

int(0)
int(1)
int(2)
int(0)
To Top