lintz
Apr 27th, 2007, 01:37 AM
I've got this line of text I'm trying to append to a text file using the below code.
$TextToAdd = "<li>SDG gave a Lighten alert.</li><li>CPB gave a Pyramid alert.</li><li>OKN gave a Pyramid alert.</li><li>SHR gave a Lighten
alert.</li><li>TRU gave a Pyramid alert.</li><li>BEN gave a Buy alert.</li><li>NAB gave a Sell alert.</li>";
$linebreak = "\r\n";
//name of file to add info
$filename = "test file.txt";
//Open file for append
$open_file = fopen($filename, 'a');
//add to file
fwrite($open_file, $TextToAdd);
//add line break
fwrite($open_file, $linebreak);
//Close file
fclose($open_file);
However, when I open the file the text has been split up over several lines and looks like this?? :confused:
<li>SDG gave a Lighten
alert.</li><li>CPB gave a Pyramid
alert.</li><li>OKN gave a Pyramid
alert.</li><li>SHR gave a Lighten
alert.</li><li>TRU gave a Pyramid
alert.</li><li>BEN gave a Buy
alert.</li><li>NAB gave a Sell
alert.</li>
Why is this happening and how can I ensure the text is displayed on 1 line of the text file?
$TextToAdd = "<li>SDG gave a Lighten alert.</li><li>CPB gave a Pyramid alert.</li><li>OKN gave a Pyramid alert.</li><li>SHR gave a Lighten
alert.</li><li>TRU gave a Pyramid alert.</li><li>BEN gave a Buy alert.</li><li>NAB gave a Sell alert.</li>";
$linebreak = "\r\n";
//name of file to add info
$filename = "test file.txt";
//Open file for append
$open_file = fopen($filename, 'a');
//add to file
fwrite($open_file, $TextToAdd);
//add line break
fwrite($open_file, $linebreak);
//Close file
fclose($open_file);
However, when I open the file the text has been split up over several lines and looks like this?? :confused:
<li>SDG gave a Lighten
alert.</li><li>CPB gave a Pyramid
alert.</li><li>OKN gave a Pyramid
alert.</li><li>SHR gave a Lighten
alert.</li><li>TRU gave a Pyramid
alert.</li><li>BEN gave a Buy
alert.</li><li>NAB gave a Sell
alert.</li>
Why is this happening and how can I ensure the text is displayed on 1 line of the text file?