Jump to content

I need some help with the fread() function...


clonetrooper9494

Recommended Posts

I am reading the tutorial at Tizag ( http://www.tizag.com/phpT/fileread.php ) but when it reads it can olny red from the top of the page. I am trying to have it get all of the data on one line, but it doesn't say anything about that. There would be a file named 'someusername_accountinfo.txt' and on that page would be there email on the first line, there would be their address on the second, and their password on the third. but in order to get the password to check it when they login, it would have a bunch of junk before it. Is there any way to trim that stuff off, while its in the variable, or some how jump lines using fread() function? I could make a file called 'someusername_accountinfo_password.txt' and 'someusername_accountinfo_email.txt' and have apage for each chunk of data I need to store, but would that take up more space?Basiclly, two questions... how to make fread jump lines, then read. and also does making multiple files take up more space other than the name?

Link to comment
Share on other sites

Rather than fread() I like the file() function.it will return an array, each line in one of the array values:file.txt:This is some textwith a line breakSome PHP:$f = file("file.txt");echo $f[0]; // Outputs "This is some text"echo $f[1]; // Outputs "with a line break"

Link to comment
Share on other sites

You don't. file(), file_get_contents() and file_put_contents() are all functions that automate the streaming process.

Link to comment
Share on other sites

I found a good source for most of my problems...http://www.w3schools.com/php/php_ref_filesystem.aspAlthough it does not sovle this one problem...I need a page to be deleted after a certain amount of time with out any page being visited... I am making a new topic becuase this problem will be a long post and I don't want this topic to go off topic.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...