Ho bisogno di aprire un file di testo e sostituire una stringa. Ho bisogno di questoSostituisci stringa nel file di testo utilizzando PHP
Old String: <span id="$msgid" style="display: block;">
New String: <span id="$msgid" style="display: none;">
Questo è quello che ho finora, ma non vedo alcuna modifica nel file di testo, oltre a spazi bianchi extra.
$msgid = $_GET['msgid'];
$oldMessage = "";
$deletedFormat = "";
// Read the entire string
$str = implode("\n", file('msghistory.txt'));
$fp = fopen('msghistory.txt', 'w');
// Replace something in the file string - this is a VERY simple example
$str = str_replace("$oldMessage", "$deletedFormat", $str);
fwrite($fp, $str, strlen($str));
fclose($fp);
Come posso farlo?
Assicurati di avere scrivere permessi sul file msghistory.txt – Lobo
È giusto? '$ deletedFormat =" "';' –
Hai un errore di sintassi. '$ deletedFormat =" "';' hai una citazione singola extra. –