tmh766 Posted March 1, 2007 Share Posted March 1, 2007 How can you read only the last line of a file without reading the entire file? I have a log and only need the most recent line of data which is at the end. Link to comment https://forums.phpfreaks.com/topic/40640-solved-read-only-last-line-of-a-file/ Share on other sites More sharing options...
btherl Posted March 1, 2007 Share Posted March 1, 2007 If you are running on unix, you can do $last_line = exec("/usr/bin/last $file"); Don't do that if $file was passed in as an argument to the script, as that would be a major security risk. Link to comment https://forums.phpfreaks.com/topic/40640-solved-read-only-last-line-of-a-file/#findComment-196571 Share on other sites More sharing options...
tmh766 Posted March 1, 2007 Author Share Posted March 1, 2007 Thanks! Link to comment https://forums.phpfreaks.com/topic/40640-solved-read-only-last-line-of-a-file/#findComment-196582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.