Replacing file content in PHP

前端 未结 3 1229
忘掉有多难
忘掉有多难 2020-12-18 18:43

I need a function just like preg_replace but instead of strings I need it to work with files / file content.

3条回答
  •  别那么骄傲
    2020-12-18 19:18

    You can do:

    $file = 'filename';
    file_put_contents($file,str_replace('find','replace',file_get_contents($file)));
    

提交回复
热议问题