Função arquivo PHP ()
❮ Referência do sistema de arquivos PHPExemplo
Ler um arquivo em uma matriz:
<?php
print_r(file("test.txt"));
?>
Definição e uso
O file() lê um arquivo em um array.
Cada elemento da matriz contém uma linha do arquivo, com o caractere de nova linha ainda anexado.
Sintaxe
file(filename, flag, context)
Valores de parâmetro
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. |
Detalhes técnicos
Valor de retorno: | O arquivo inteiro em uma matriz, FALSE em caso de falha |
---|---|
Versão do PHP: | 4.0+ |
Binário Seguro: | Sim, no PHP 4.3 |
❮ Referência do sistema de arquivos PHP