Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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
 
 
Register now for full access!
Old 11-06-2009, 11:45 PM Re: How do I retrieve the last line of a file?
rogem002's Avatar
PHP Chap

Posts: 843
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 
__________________
My Blog/Site:
Please login or register to view this content. Registration is FREE
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.16367 seconds with 12 queries