Most Referenced Functions
  » google_pagerank()
  » preg_replace()
  » imagecreatefrompng()
  » site_pageranks()
  » imagepng()
  » imagestring()
  » imagedestroy()
  » htmlentities()
  » imagecolorallocate()
  » fopen()
  » preg_match()
  » header()
  » getimagesize()
  » session_start()
  » ob_start()
  » preg_match_all()
  » strstr()
  » ob_flush()
  » flush()
  » htmlspecialchars()
  » str_replace()
  » strpos()
  » array2vars()
  » nl2br()
  » setcookie()
  » urlencode()
  » preg_split()
  » ereg()
  » ereg_replace()
  » var_dump()

Become a sponsor for $15/month. Link is sitewide - PR5 homepage, 20+ PR4 pages, 90+ PR3 pages. Email dave[AT]icemelon[D0T]c0m.

PHP Functions

Function: file

(PHP 3, PHP 4, PHP 5)

file -- Reads entire file into an array

Description

array file ( string filename [, int use_include_path [, resource context]] )

Identical to readfile() , except that file() returns the file in an array. Each element of the array corresponds to a line in the file, with the newline still attached. Upon failure, file() returns FALSE .

You can use the optional use_include_path parameter and set it to "1", if you want to search for the file in the include_path , too.

<?php
// Get a file into an array.  In this example we'll go through HTTP to get 
// the HTML source of a URL.
$lines = file('http://www.example.com/');

// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
    echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
}

Related Function(s)

  • readfile()
  • fopen()
  • rtrim()
  • file_get_contents()
  • fsockopen()
  • popen()
  • include()
  • Icemelon -- PHP, CSS, Javascript Tutorials, & More!
      © 2005-2010 Icemelon.com   Email: dave[AT]icemelon[D0T]c0m