Jump to content

Recommended Posts

I created a form that accepts a user's first and last name, and also a script that saves this data to a text file. After each time a user submits the form, the entry is then written to a new line in my txt document (I'm using the \n to achieve this) That part really wasn't a problem. 

 

It's the second half of what I'm trying to do that's causing a little confusion. I want to print a summary that includes the number of lines in my text file, as well as the file's size. You'll see from my code that I have been able to do everything except summarize the number of lines in my text file  .Any help would be very much appreciated.. here is the code I am working with, and I thank you in advance:

 

------------------------------------------------

<?php

 

$filename="people_processed.txt";

$fp = fopen ($filename, "r") or die("Couldn't open $filename");

while (! feof($fp)) {

  $line = fgets($fp, 1024);

  print "$line<br />";

}

 

 

// Below is code that will tell me how

// big my file size is getting.

print "<br />";

print "<br />";

print "The file size of people_processed.txt is ";

print filesize("people_processed.txt");

print " bytes."

 

?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.