[PHP] file()

file() (funzione PHP) legge un intero file e restituisce un array numerico, di cui ogni elemento è una riga del file stesso.

tips&tricks

Sintassi

file($file, $opzioni[facoltativo])
parametro descrizione
$file Il file da processare
$opzioni Le opzioni di letture, secondo i seguenti valori testuali:
FILE_USE_INCLUDE_PATH Search for the file in the include_path.
FILE_IGNORE_NEW_LINES Do not add newline at the end of each array element
FILE_SKIP_EMPTY_LINES Skip empty lines

Esempi

print_r(file("prova.txt"));

/* RISULTATO
Array
(
[0] => Prima riga del file.
[1] => Seconda riga del file.
[2] => Terza riga del file
)
*/

Contenuti correlati

Fonti esterne

funzioni php, php

Related Articles

0 Comment