note 20725 added to function.fwrite
| From: | tyleria_lysNOSPAM at freemail dot NO_SPAM dot ch | Date: | Sun, 14 Apr 2002 09:21:23 +0000 |
| Subject: | note 20725 added to function.fwrite | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29258@lists.php.net to get a copy of this message | ||
Setting a new line on textfile in appendmode
It took me a while to find out how to set a new line in a textfile which i opened in append-mode (a)
on a windows-system. If you use the way, Jerry has posted-he uses overwrite (w) instead of (a)- but
in append-mode, it won't work unless you add another line, with the methode Steffen has been
posting ('fputs(file,"\n"'). Well, so i designed a little script what i use to
create a protocoll while executing a function on website. The following part will append any content
of the parsed array in a new line on the file:
//---------------WRITE MESSAGE TO PROTOCOLL-FILE
$filename= "yourfile";
$fd = fopen($filename, "a");
foreach ('$yourarray' as $text){
$content=$text;
fwrite($fd, $content);
fwrite($fd, chr(13));
fwrite($fd, "\n");
}
fclose($fd);
//end of writing
you can use this little script to read out and write down information of arrays of any lenght. But
don't forget to check out filesize from time to time to avoid files of over 20kb and more (as
smaller as faster your read them out).
Enjoy
Tyleria
--
http://www.php.net/manual/en/function.fwrite.php
http://master.php.net/manage/user-notes.php?action=edit+20725
http://master.php.net/manage/user-notes.php?action=delete+20725
http://master.php.net/manage/user-notes.php?action=reject+20725