RE: [PHP-GENERAL] Reversing the order of a text file

From: Date: Wed, 31 May 2000 17:12:38 +0000
Subject: RE: [PHP-GENERAL] Reversing the order of a text file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-737@lists.php.net to get a copy of this message
Simply do something like this: $file = file("file.txt"); $num = count($file); if ($num > 1){ while ($num !=-1){ echo $file($num) . "<br>"; $num = $num - 1; } } What this does is it reads in all the lines of the text file into the $file array. Next, a count is done to determine how many lines are in the $file array, then a loop is run to print everything from the bottom of the array up to the top. Hope this helps.. Chris -----Original Message----- From: Brian C. Doyle [mailto:bcdoyle@mindspring.com] Sent: Wednesday, May 31, 2000 12:56 PM To: php-general@lists.php.net Subject: [PHP-GENERAL] Reversing the order of a text file Hello, I have a file info.txt that is a list. I want to read the file in reverse order. How do i go about doing this? Thanks in advance. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#737) next »