PHP Doku:: Seek to specified line - splfileobject.seek.html

Verlauf / Chronik / History: (4) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige GrunderweiterungenStandard PHP Library (SPL)DateibehandlungThe SplFileObject classSplFileObject::seek

Ein Service von Reinhard Neidl - Webprogrammierung.

The SplFileObject class

<<SplFileObject::rewind

SplFileObject::setCsvControl>>

SplFileObject::seek

(PHP 5 >= 5.1.0)

SplFileObject::seekSeek 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


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)