Delete only one phrase from a file using php

Asked

Viewed 44 times

1

I want to delete just one phrase from everywhere it appears in the file, has some function that does this, something that can help me or that is impossible. I tried, but all I got was a headache.

  • 1

    What type of file is this? TXT?

  • I’m not using a format of my own, it’s a . Apr

  • 1

    php opens this file type . Apr?

  • not only opens but edits

1 answer

6


$caminho = 'caminho/do/arquivo.txt';
$conteudo = file_get_contents($caminho);
file_put_contents($caminho, str_replace('trocar isto', 'por isto', $conteudo));
  • 1

    Deleting is exchanging for ''.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.