Writing in txt file...

From: Date: Thu, 20 Feb 2003 18:59:25 +0000
Subject: Writing in txt file...
Groups: php.windows 
Request: Send a blank email to php-windows+get-18638@lists.php.net to get a copy of this message
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 (#18638) next »