Jump to: navigation, search

Php file

From w3cyberlearnings

Contents

PHP function file

This function reads entire content of a file as array.

Syntax file

  • file: file name or path to the file
  • mode (optional): specifies file search location and how to read file content
    • FILE_USE_INCLUDE_PATH: search file in the include_path.
    • FILE_IGNORE_NEW_LINES: Do not add newline at the end of each array
    • FILE_SKIP_EMPTY_LINES: SKip empty lines
  • context (optional):A context resource created with the stream_context_create() function.
file(file, mode, context);

File Content (myfile.txt)

The Rest of the world.
The Rest of the nations.

Example 1

<?php

$file_content = file("myfile.txt");

print_r($file_content);
?>

Output


Array
(
    [0] => The Rest of the world.


    [1] => The Rest of the nations.


)

Related Links


basename-- chgrp-- chmod-- chown-- clearstatcache-- copy-- delete-- dirname-- disk_free_space-- disk_total_space-- diskfreespace-- fclose-- feof-- fflush-- fgetc-- fgetcsv-- fgets-- fgetss-- file_exists-- file_get_contents-- file_put_contents- file-- fileatime-- filectime-- filegroup-- fileinode-- filemtime-- fileowner-- fileperms-- filesize-- filetype-- flock-- fnmatch-- fopen-- fpassthru-- fputcsv-- fputs-- fread-- fscanf-- fseek-- fstat-- ftell-- ftruncate-- fwrite-- glob-- is_dir-- is_executable-- is_file-- is_link-- is_readable-- is_uploaded_file-- is_writable-- is_writeable-- lchgrp-- lchown-- link-- linkinfo-- lstat-- mkdir-- move_uploaded_file-- parse_ini_file-- parse_ini_string-- pathinfo-- pclose-- popen-- readfile-- readlink-- realpath_cache_get-- realpath_cache_size-- realpath-- rename-- rewind-- rmdir-- set_file_buffer-- stat-- symlink-- tempnam-- tmpfile-- touch-- umask-- unlink--

Navigation
Web
SQL
MISC
References