Lets say I have this data in a file (externalfile.txt)
#1#First#/1#
#2#Something#/2#
#end#
I want to write text between #/2# and #end#, How to do this?
Lets say I have this data in a file (externalfile.txt)
#1#First#/1#
#2#Something#/2#
#end#
I want to write text between #/2# and #end#, How to do this?
Not sure if it's the proper way but you may take a look
$newval='new text';
$file_contents = file_get_contents('externalfile.txt');
file_put_contents('externalfile.txt', preg_replace("/#\/2#/", "#/2#\n$newval\n", $file_contents));
It works, anyway.