php8.5
Home/ Manual/ spl / splfileobject/ SplFileObject::next

SplFileObject::next

PHP function Edit on GitHub ✎

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

Read next line

Description

SplFileObject::next(): void

Moves ahead to the next line in the file.

Parameters Parameters

Return Values

Void

Examples

SplFileObject::next example

php
<?php
// Read through file line by line
$file = new SplFileObject("misc.txt");
while (!$file->eof()) {
    echo $file->current();
    $file->next();
}
?>

See Also

  • SplFileObject::current
  • SplFileObject::key
  • SplFileObject::seek
  • SplFileObject::rewind
  • SplFileObject::valid

Source: reference/spl/splfileobject/next.xml · from the official PHP manual (php/doc-en)