i have a text file i want to read it's contents line by line
that first line contents are this
2nd line coontents are this
plz help if ossible plz send code
how to read a line
Howdy...
The simple way to read a line at a time is to use fgets. This is straight from the PHP website.
$fp = fopen('tmp/inputfile.txt' 'rb');
while(!feof($fp)) {
echo fgets($fp, 4096);
}
fclose($fp);
Basically, the fgets function returns the current line from the open file, and advances the file pointer to the next line.
http://www.php.net/manual/en/function.fgets.php
Cheers,
Matt
Use the PHP file() function... This returns an entire file in an array where the elemnts are the lines of the file. So....
$myfile = file("yourfile.txt");
echo "Line 1 is: " . $myfile[1] . "<br>\n";
echo "Line 2 is: " . $myfile[2] . "<br>\n";
etc...
-Josh B
RTFM: http://php.net/file