è la prima volta che mi trovo a lavorare con i .txt e non so da dove cominciare
è gradito ogni link, pillola o funzione utile
Grazie
cichity74
è la prima volta che mi trovo a lavorare con i .txt e non so da dove cominciare
è gradito ogni link, pillola o funzione utile
Grazie
cichity74
guardati nella documentazione le funzioni:
fopen
fwrite
fread
fclose
e fatti anche una ricerca nel forum... è pieno di discussioni...
Ho un problema...codice:<?php $_SESSION['my_txt'] = 1; $file_txt = array ("te1","te2","te3","te4","te5","te_prof"); if ( $_SERVER['REQUEST_METHOD'] == 'POST' && array_key_exists('testo', $_POST) ){ $testo = trim($_POST['testo']); //------------------------------------------------------ $file = "./" . $file_txt[$_SESSION['my_txt']] . ".txt"; $handle = fopen($file, 'r+'); fwrite($handle, $testo); fclose($handle); //------------------------------------------------------ } ?>
in questo modo mi aggiunge il nuovo testo all'esistente
vorrei prima svuotare il file txt
e poi scriverci il testo
come posso fare![]()
$handle = fopen($file, 'w');Originariamente inviato da cichity74
Ho un problema...codice:<?php $_SESSION['my_txt'] = 1; $file_txt = array ("te1","te2","te3","te4","te5","te_prof"); if ( $_SERVER['REQUEST_METHOD'] == 'POST' && array_key_exists('testo', $_POST) ){ $testo = trim($_POST['testo']); //------------------------------------------------------ $file = "./" . $file_txt[$_SESSION['my_txt']] . ".txt"; $handle = fopen($file, 'r+'); fwrite($handle, $testo); fclose($handle); //------------------------------------------------------ } ?>
in questo modo mi aggiunge il nuovo testo all'esistente
vorrei prima svuotare il file txt
e poi scriverci il testo
come posso fare![]()
Penso che possa andare