Re: text file

From: Date: Wed, 05 Jun 2002 23:13:02 +0000
Subject: Re: text file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-100829@lists.php.net to get a copy of this message
Take a look at following functions: http://www.php.net/manual/en/function.file.php http://www.php.net/manual/en/function.array-unshift.php -philip On Wed, 5 Jun 2002, John Taylor-Johnston wrote: > I want to open a text file which has 12 lines and > (1) insert a new line at line[0] > (2) re-save the text file only with 12 lines (Therefore line[12] gets > chopped out. > > I had some code to do this with Perl. > > open (NEW, ">$filepath\\$file"); > print NEW "$something"; > for ($i = 2; $i < 12; $i++) > { > print NEW "$lines[$i]"; > print "$lines[$i]"; > } > > How can I do it now with PHP? > Open the file (http://www.php.net/manual/en/function.fopen.php) > Suck a text file into an array. <-------?? > Insert at line[0] <-------?? > and rewrite the file. > (http://www.php.net/manual/en/function.fopen.php) > > > John > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#100829) next »