Hello, i am new here :) and i have - maybe simple - question. How to put new line to txt file (file_put_contents - FILE_APPEND) above the text. My script puts new line under the contents and that's not good for me.
Thank you
<?php
include('class-search.php');
$html = file_get_html('http://deluxetelevision.com/deluxe-radio/');
$polozka = $html->find('span.playlist_stunde_time');
foreach($polozka as $playlist)
echo $playlist->plaintext . '<br />';
$file = 'playlist.txt';
foreach($polozka as $playlist)
{
file_put_contents($file, $playlist->plaintext ."\n", FILE_APPEND);
}
?>
_Aerospace_Eng_
03-09-2010, 10:50 PM
The simplest way would be to do a file_put_contents outside of the foreach however you may need to truncate the file first and then use the foreach to append the contents.