Delete only one sentence from a file using php

1

I want to delete only one sentence from all places where it appears in the file, have some function that does this, something that can help me or this is impossible. I tried, but I only got a headache.

    
asked by anonymous 02.08.2017 / 03:06

1 answer

6
$caminho = 'caminho/do/arquivo.txt';
$conteudo = file_get_contents($caminho);
file_put_contents($caminho, str_replace('trocar isto', 'por isto', $conteudo));
    
02.08.2017 / 03:13