Dunque, se scrivo a mano un file txt con il pc e stampo ciclicamente i dati, tutto funziona.
Il txt ha questa struttura:
aaa::bbb::ccc::ddd\r\n
aaa2::bbb2::ccc2::ddd2\r\n
Ora ho un form di inserimento per andare ad aggiungere le righe al file.
Ma quando torno a leggere il txt mi viene mostrato solo la prima righa
Le righe le estraggo cosi:
Codice PHP:
if(file_exists("../music/webradio.txt")) {
$lines = file("../music/webradio.txt");
$n_lines = count($lines);
for($c = 0; $c<$n_lines; $c++)
{
$dati = explode("::", $lines[$c]);
$play = $dati[3];
if($play == 1) { //stampo solo gli mp3 attivi 1
echo "<div class=\"mp3\">";
echo "<a href=\"box/mamito_radio.php?mp3=".$dati['0']."\" onclick=\"return caricaTesto(this.href);\" onkeypress=\"return this.onclick();\" tabindex=\"1\">".$dati['1']."</a>".$dati['2']." ";
echo "</div>";
}
}
}
ù
mentre l'inserimento viene fatto cosi
Codice PHP:
$old_content = file_get_contents("music/webradio.txt");
$filename = 'music/webradio.txt';
$content = ''.$nomefile.'::'.$commento.'::'.$autore.'::1\r\n
'.$old_content.'';
$handle = fopen($filename, 'w');
fwrite($handle, $content);
fclose($handle);
Come accade ciò?