0

In the following text file (file.txt):

1 Hello!
2 How
3 and
4 you?

I would like to replace line 3 with the following statement:

3 are

Do you have a solution to find the line number and replace it with the specified value? Of course, without the use of a FENDER or REPLACE for word.

ba haran
  • 15
  • 5
  • Have you tried anything so far? – Nigel Ren Dec 12 '19 at 08:23
  • I've already tried finding the word. But that word may change later. I didn't find anything for the idea I came up with. – ba haran Dec 12 '19 at 08:25
  • Have a look at [`file()`](https://www.php.net/manual/en/function.file.php). – Nigel Ren Dec 12 '19 at 08:26
  • What about using explode with CR or LF character ? – Flyzzx Dec 12 '19 at 09:22
  • Hello Flyzzx! Can you give any more explanation? – ba haran Dec 12 '19 at 09:26
  • Does this answer your question? [how to replace a particular line in a text file using php?](https://stackoverflow.com/questions/3004041/how-to-replace-a-particular-line-in-a-text-file-using-php) – Don't Panic Dec 12 '19 at 10:35
  • There are so many duplicates of this here on SO, please try searching before posting a new question. If your case is different, reference the answers you've tried and describe why yours is different or doesn't work. – Don't Panic Dec 12 '19 at 10:36

0 Answers0