<?php $file = '1.txt'; $a = '9878687'; //После чего вставить $b = 'hg788gjlо'; //Что вставить $open = file_get_contents($file); file_put_contents($file, str_replace($a, $a."\r\n".$b, $open)); ?>