I have this function:
<?php
$post="marie" . "\n"; // \n not working?
//replace txt
$oldMessage = $post;
$deletedFormat = "";
//read the entire string
$str=file_get_contents('log.txt');
//replace something in the file string - this is a VERY simple example
$str=str_replace("$oldMessage", "$deletedFormat",$str);
//write the entire string
file_put_contents('log.txt', $str);
?>
I want to find marie
and replace it:
ANAff
marieb
marie
mariec
marie
So it should replace only the 3 one, but the result was:
ANAff
b
c
In other words, I want to remove the exactly $post value from log.txt. how to do this? And if possible, how to remove the full line? not let it blank.