How to delete a line from the file with php?

后端 未结 9 1331
北荒
北荒 2020-11-27 19:36

I have a file named $dir and a string named $line, I know that this string is a complete line of that file but I don\'t know its line number and I

9条回答
  •  有刺的猬
    2020-11-27 20:07

    Like this:

    file_put_contents($filename, str_replace($line . "\r\n", "", file_get_contents($filename)));
    

提交回复
热议问题