私はこの機能を持っている:単語をtxtから削除して保存します。全く同様の言葉
<?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);
?>
私はmarie
を見つけ、それを交換したい:
ANAff
marieb
marie
mariec
marie
だから、わずか3 1を置き換えるべきではありませんが、結果はでした:
ANAff
b
c
つまり、正確に$ post値をlog.txtから削除したいと考えています。これを行う方法? 可能であれば、フルラインを削除する方法は?それを空白にしないでください。
ないその質問が良いそのものですが、その要件は確かにもあると面白いです:) –