note 19248 added to function.fwrite

From: Date: Wed, 20 Feb 2002 20:34:27 +0000
Subject: note 19248 added to function.fwrite
Groups: php.notes 
Request: Send a blank email to php-notes+get-26865@lists.php.net to get a copy of this message
I needed to have a new line after some data... and it took me awhile to figure it out since I'm new to this. Thought I would pass it along. <html> <title>File Write Experiment</title> <body> We will attempt to write a file called "test.dat" and store some stuff in it.<br> <?php $myfile = fopen("test.dat","w"); print "The file $myfile should now be opened.<br>"; print "<HR>"; $number=0; while($number<5) { print "Now writing... $number <br>"; $fp = fwrite($myfile,"$number,"); $number++; } $fp = fwrite($myfile,$number); $fp = fwrite($myfile,chr(13)); $fp = fwrite($myfile,"DONE"); fclose($myfile); ?> The file should now be closed. </body> </html> The command chr(13) writes a carrage return... in a text file this causes a new line. The output from the above would then be: 0,1,2,3,4,5 DONE hope it helps, Jerry -- http://www.php.net/manual/en/function.fwrite.php http://master.php.net/manage/user-notes.php?action=edit+19248 http://master.php.net/manage/user-notes.php?action=delete+19248 http://master.php.net/manage/user-notes.php?action=reject+19248

« previous php.notes (#26865) next »