array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'splfileobject.rewind.php', 1 => 'SplFileObject::rewind', 2 => 'Rewind the file to the first line', ), 'up' => array ( 0 => 'class.splfileobject.php', 1 => 'SplFileObject', ), 'prev' => array ( 0 => 'splfileobject.next.php', 1 => 'SplFileObject::next', ), 'next' => array ( 0 => 'splfileobject.seek.php', 1 => 'SplFileObject::seek', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/spl/splfileobject/rewind.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
SplFileObject::rewind — Rewind the file to the first line
此函数没有参数。
没有返回值。
Throws a RuntimeException if cannot be rewound.
示例 #1 SplFileObject::rewind() example
<?php
$file = new SplFileObject("misc.txt");
// Loop over whole file
foreach ($file as $line) { }
// Rewind to first line
$file->rewind();
// Output first line
echo $file->current();
?>