Insert text to particular position in a file
Posted: Tue Jun 08, 2010 2:30 am
Hi friends,
I am a newbie in string functions in php. I have a text file which contains some lines of text in a particular format.
I am using php to maniputlate this text file.
[text]
Text1 = This is my first line of text
Text2 = This is my second text
Text3 = This is my third text
Text5 = This is fifth line of text
Text10 = This is tenth line in the file
....
....[/text]
I would like to insert some missing text at the end or in between the existing lines. For example, I would like to write Text7 in the file in the exact place now. Can anyone please give me a solution for this?
After the insertion, the file should look like this:
[text]Text1 = This is my first line of text
Text2 = This is my second text
Text3 = This is my third text
Text5 = This is fifth line of text
Text7 = This is seventh line in the file
Text10 = This is tenth line in the file
....
....[/text]
I am a newbie in string functions in php. I have a text file which contains some lines of text in a particular format.
I am using php to maniputlate this text file.
[text]
Text1 = This is my first line of text
Text2 = This is my second text
Text3 = This is my third text
Text5 = This is fifth line of text
Text10 = This is tenth line in the file
....
....[/text]
I would like to insert some missing text at the end or in between the existing lines. For example, I would like to write Text7 in the file in the exact place now. Can anyone please give me a solution for this?
After the insertion, the file should look like this:
[text]Text1 = This is my first line of text
Text2 = This is my second text
Text3 = This is my third text
Text5 = This is fifth line of text
Text7 = This is seventh line in the file
Text10 = This is tenth line in the file
....
....[/text]