Jump to content

Insert text to particular position in a file


ashly123

Recommended Posts

Hi,

 

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.

 

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
....
....

 

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:

 

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
....
....

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.