I want to save the result for a loop with enter using this code
$str = '';
for( $i = 1; $i <= 10; $i++ ) {
$str .= $i;
}
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = $str . "\n";
fwrite($myfile, $txt);
fclose($myfile);
but the result
12345678910
I want the result to be like
1
2
3
4
5
6
7
8
9
10
then i am trying to use this script
$str = '';
for( $i = 1; $i <= 10; $i++ ) {
$str .= $i . "<br>";
}
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = $str . "\n";
fwrite($myfile, $txt);
fclose($myfile);
similar result
1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>10<br>
can anyone help me fix this script please?
source
share