Reply
How do I retrieve the last line of a file?
Old 11-06-2009, 12:21 PM How do I retrieve the last line of a file?
Average Talker

Posts: 19
Name: Meir Ech
Trades: 0
I go through a file using
WHILE(! feof()), during which
I write to a file ($wfile).

Once done, I need to make a change
in the last line of the output file.

How do I do this?
ruffy is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 11-06-2009, 11:45 PM Re: How do I retrieve the last line of a file?
rogem002's Avatar
Super Spam Talker

Latest Blog Post:
Making Zebra Stripes with CSS3
Posts: 835
Name: Mike
Location: United Kingdom
Trades: 0
The simplest way to do this is using the file(http://uk2.php.net/manual/en/function.file.php) function:
PHP Code:
// taken from: http://stackoverflow.com/questions/1062716/php-returning-the-last-line-in-a-file
$file "/path/to/file";
$data file($file); // this will return an array of the data
$line $data[count($data)-1]; // this will return the last child in the array 
__________________
PHP Code:
Add_Talkupation('rogem002'); // Because sharing is awesome! 
Fix 90% of your problems | Full On Design
rogem002 is offline
Reply With Quote
View Public Profile Visit rogem002's homepage!
 
Reply     « Reply to How do I retrieve the last line of a file?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.10122 seconds with 13 queries