Re: Writing to files

From: Date: Fri, 11 Jul 2003 19:43:55 +0000
Subject: Re: Writing to files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-154927@lists.php.net to get a copy of this message
Hello, This is a reply to an e-mail that you wrote on Fri, 11 Jul 2003 at 20:37, lines prefixed by '>' were originally written by you. > Any ideas on how I can print the lines of my file in reverse order, > then? How about... $fp = fopen("yourfile.txt","r"); $filecontents = ""; while(!feof($fp)){ $filecontents.=fgets($fp,1024); // read entire file into $filecontents } $filelines = split("\n",$filecontents); // split file into individual lines for($i=(count($filelines)-1);$i>=0;$i--){ // loop through array in reverse order echo $filelines[$i] . "\n"; } -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ (developed entirely in PHP)

« previous php.general (#154927) next »