Hello 2013/7/29, Aritra Hazra <ari...@gmail.com>: > Hi, I've been using PHP for several years and I take is as my primary > priority for making web applications. But recently I'm having a problem in > file reading. I have a huge file containing simple text data. Whatever I > append to the file it adds at the bottom, It's OK but, I want to read the > file from the bottom by lines and I couldn't find any appropriate function > to do this, and as It's a huge file (50mb+) it takes forever to load by the > formal way from the start. So I'm requesting PHP crew to add a function > that can read files backwards from the end by lines. It'll be a huge help > for me including many programmers :-)
This should go to the general support list, see[1]. You should use fopen(), which will only open a file pointer to the file, then you can use fseek(), combined with filesize() to calculate the position you wish to start reading from: function frseek($fp, $pos) { return(fseek($fp, fseek($fp, 0, SEEK_END) - $pos)); } Ofcourse this will only read chunks, but you can always use it to implement a 'reverse' file() function yourself. If you wish to go into depth and implement it yourself in C, you can write an RFC and request access to the wiki by introducing yourself on this list (webmaster). [1] http://php.net/mailinglists -- regards, Kalle Sommer Nielsen ka...@php.net -- PHP Webmaster List Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php