Originariamente inviato da cichity74
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);
		//------------------------------------------------------
	}

?>
Ho un problema...
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');

Penso che possa andare