PHP file() Funktion
❮ Referenz zum PHP-DateisystemBeispiel
Lesen Sie eine Datei in ein Array:
<?php
print_r(file("test.txt"));
?>
Definition und Verwendung
Die file() liest eine Datei in ein Array.
Jedes Array-Element enthält eine Zeile aus der Datei, wobei das Zeilenumbruchzeichen noch angehängt ist.
Syntax
file(filename, flag, context)
Parameterwerte
Parameter | Description |
---|---|
filename | Required. Specifies the path to the file to read |
flag |
Optional. Can be one or more of the following constants:
|
context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream. Can be skipped by using NULL. |
Technische Details
Rückgabewert: | Die gesamte Datei in einem Array, FALSE bei Fehler |
---|---|
PHP-Version: | 4.0+ |
Binär sicher: | Ja, in PHP 4.3 |
❮ Referenz zum PHP-Dateisystem