note 19248 deleted from function.fwrite by hholzgra
| From: | hholzgra@php.net | Date: | Fri, 12 Jul 2002 14:55:10 +0000 |
| Subject: | note 19248 deleted from function.fwrite by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-32972@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