I need to open a text file and replace a string. I need this
Old String: <span id="$msgid" style="display: block;">
New String: <span id="$msgid" style="display: none;">
This is what I have so far, but I don't see any changes in the text file besides extra white spaces.
$msgid = $_GET['msgid'];
$oldMessage = "";
$deletedFormat = "";
// Read the entire string
$str = implode("
", 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);
How can I do it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…