Portal Home > Knowledgebase > Articles Database > PHP Help


PHP Help




Posted by CowHosts, 05-06-2011, 02:24 PM
Hey, I'm not sure what section this should go in but here it goes anyway. I need to basically grab some data from an external .txt file. I only need the bottom line of the file. I know a code which will echo the top value of the file, anyone know how to change this to the bottom value? Here's the code: Thanks.

Posted by WootWoot, 05-06-2011, 03:29 PM
Hi there, Here's one (efficient) way to achieve what you want :

Posted by CowHosts, 05-06-2011, 05:08 PM
Hey WootWoot, I really appreciate your reply. I have tried out this code, looks like it should work and I got some kind of PHP error. It doesn't make much sense to me can you make anything out of it? Warning: fseek() [function.fseek]: stream does not support seeking in /home/directory/index.php on line 7 Warning: fseek() [function.fseek]: stream does not support seeking in /home/directory/index.php on line 17

Posted by WootWoot, 05-06-2011, 05:28 PM
Hum... This piece of code shall work fine. Have you replaced "file.txt" with your own file name? Is it a .txt file? Are you sure this file exists and is properly CHMODed? If the file isn't that big, you may simply use :

Posted by adamhahnderson, 05-08-2011, 04:57 AM
In the case of large files, I typically use this method: The $output array, in this case, would contain the last line of myfile.txt. I find this method convenient for looking at apache log files, or any files that have lots of line breaks.

Posted by CowHosts, 05-08-2011, 06:11 AM
Hello, Thanks both of those worked. I appreciate your time in helping me out with this. CowHosts

Posted by saimaspider, 05-08-2011, 09:19 PM
Thanks for the reply good solution



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
Apache alternative (Views: 521)