Re: Writing new lines in txt- files?

From: Date: Thu, 24 Jan 2002 09:25:18 +0000
Subject: Re: Writing new lines in txt- files?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-81961@lists.php.net to get a copy of this message
Sample script for writing to a file: if ($fp = fopen("/path/to/file", "w")) { fwrite($fp, $text . "\n", strlen($text)); } else { ... code to report error opening file } You can use a loop for writing, obviously, if you have to write more than one line (as it sounds like you do). Just create a while() loop that gets a line or a certain length of text from a source and write it until you reach the end of the source. Just remember to add the "\n" and you'll get each line read from the source written to its own line on the destination file. Mike Frazer "Mëòv î?çîÎ òsyïn" <vanvettig@hotmail.com> wrote in message news:F163pe5dCmjMAokmBRp0000aea9@hotmail.com... > Hello folks! > > I want to write to a textfile, but I want a row for each string I write to > the file. As it is now when I write to the file it just starts writing where > the last string ends.. > > What should I do? =) > > Thanks! //M. > > > > > ---------------------------------------------- > Mårten Andersson > Loddbygatan 2 > 60218 Norrköping > > URL: http://www.vanvett.net/marten > email: sillstryparen@vanvett.net > ICQ: 86515830 > > > _________________________________________________________________ > Kom med i världens största e-posttjänst; MSN Hotmail. > http://www.hotmail.com/sv >

« previous php.general (#81961) next »