Jump to content

read the whole text file


phppaper

Recommended Posts

www.php.net/file

 

... will read the file into an array where each line in the file is an array element.

 

www.php.net/file_get_contents

 

... will read the whole file into a string varable.

 

Or, you can use fgets() in a loop

$fp = fopen('myfile.txt', 'r');
while (!feof($fp))
{
       $line = $fgets($fp);
       // process line
}
fclose($fp);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.