Funkce PHP file() .
❮ Reference souborového systému PHPPříklad
Přečíst soubor do pole:
<?php
print_r(file("test.txt"));
?>
Definice a použití
File() načte soubor do pole.
Každý prvek pole obsahuje řádek ze souboru se stále připojeným znakem nového řádku.
Syntax
file(filename, flag, context)
Hodnoty parametrů
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. |
Technické údaje
Návratová hodnota: | Celý soubor v poli, FALSE při selhání |
---|---|
Verze PHP: | 4,0+ |
Binární trezor: | Ano, v PHP 4.3 |
❮ Reference souborového systému PHP