Re: Reversing the order of a text file
| From: | Brian C. Doyle | Date: | Wed, 31 May 2000 17:04:44 +0000 |
| Subject: | Re: Reversing the order of a text file | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-738@lists.php.net to get a copy of this message | ||
Chris,
I need to sort it backwards... reverseing the order of the lines in the file. currently i have:<?
$fp=Fopen("file.txt","r");
while (!feof($fp)) {
$buffer = fgets($fp, 4096);
echo nl2br($buffer);
}
?>
And this reads the file into the page nicely but i want the last line first ect?At 12:06 PM 5/31/00 -0400, Chris Moyer wrote:
On Wed, May 31, 2000 at 12:55:39PM -0400, Brian C. Doyle wrote:I have a file info.txt that is a list. I want to read the file in reverseorder. How do i go about doing this? What do you mean by reverse order, reverseing every character, or each line? You could read the whole file into an array with file(), and then simply sort the array backwards if you simply need to manipulate the order of the lines. -- Chris Moyer -- cmoyer@chekinc.com --PHP Developer -- Chek.com