SplFileObject::seek

Seek to specified line

Beschreibung

public void SplFileObject::seek ( int $line_pos )

Seek to specified line in the file.

Parameter-Liste

line_pos

The zero-based line number to seek to.

Rückgabewerte

Es wird kein Wert zurückgegeben.

Fehler/Exceptions

Throws a LogicException if the line_pos is negative.

Beispiele

Beispiel #1 SplFileObject::seek example

This example outputs the third line of the script which is found at position 2.

<?php
$file 
= new SplFileObject(__FILE__);
$file->seek(2);
echo 
$file->current();
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

$file->seek(2);

Siehe auch

  • SplFileObject::current
  • SplFileObject::key
  • SplFileObject::next
  • SplFileObject::rewind
  • SplFileObject::valid