Re: Writing in txt file...

From: Date: Fri, 21 Feb 2003 08:22:14 +0000
Subject: Re: Writing in txt file...
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-18649@lists.php.net to get a copy of this message
Why dont open for append $fp=fopen("file.txt","a"); fputs($fp,"New line?"); Or i didnt understand what do u need? "Afan Pasalic" <phplist@captainjack.com> wrote in message news:5.2.0.9.0.20030220135221.00a679e8@mail.captainjack.com... > Hi, > I'm working on adding a new row in text file. I use file() to transfer file > to array and then after recognizing the row with MARK_HERE hadd new row > above the MARK row. It works fine. I use this code: > > $AddContent = "Content of the new line..."; > > $lines = file('old_content.txt'); > for($i=0; $i<count($lines); $i++) > { > echo "$i. $lines[$i]<br>"; > if(ereg('### MARK_HERE New row comes above this one', $lines[$i])) > { > $NewArray[] = $AddContent; > } > $NewArray[] = $lines[$i]; > } > > But what then? Code to add new line works fine but can't convert/write back > to new_content.txt file. looking for something opposite then file() - > taking array and writing it in file... > > Thanks for any help! > > > Afan >

« previous php.windows (#18649) next »