phppaper Posted May 23, 2008 Share Posted May 23, 2008 Hello all, I am using fgets() to read one line of a text file. But what if I have a text file with text more than one line?? what PHP function should I use?? Thanks!! Link to comment https://forums.phpfreaks.com/topic/106895-read-the-whole-text-file/ Share on other sites More sharing options...
bilis_money Posted May 23, 2008 Share Posted May 23, 2008 file() Link to comment https://forums.phpfreaks.com/topic/106895-read-the-whole-text-file/#findComment-547930 Share on other sites More sharing options...
Barand Posted May 23, 2008 Share Posted May 23, 2008 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); Link to comment https://forums.phpfreaks.com/topic/106895-read-the-whole-text-file/#findComment-547932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.