I'm trying to create a script that will take user-defined data from an html form, write it to a local text file, then display the text files contents, size of the text file, and the number of lines, all in the browser. This script is really of no use other then to practice my file reading/writing. Now I have everything working, its just I cannot for the life of me figure out how to read the text file and output how many lines it has. No clue at all. This is my best try:
$amount=0;
$fp=fopen("/home/user/Desktop/test.txt", 'r');
while ( ! feof($fp)) {
$line = fgets( $fp, 1024 );
$amount++;
}
print $amount;
I'm still very much new to PHP and programming in general, so the answer is probably staring at right at me. Am I on the right track with this?