how can i replace a specific line in text file using php?

Dav C

New member
how do i replace a particular line in a text file with an array string?

example:

text file contains the following

red,brown,green,black
black,green,red,brown
green,black,brown,red

so if i have $array = "purple,grey,pink,cyan";

how can i use fwrite to replace line 2 in text file which is green,black,brown,red with $array

i want to replace the whole line 2 with the arrray string.
 
Back
Top