The following code should do the trick to locate and insert strings into random locations. From there you would just need to re-write the file. This is a very crude way and does not take into account punctuation or anything like that, so some fine-tuning will most likely be necessary.
$save = array();
$words = str_word_count(file_get_contents('somefile.txt'), 1);
if (count($words) <= 200)
$save = $words;
else {
foreach ($words as $word) {
$save[] = $word;
$rand = rand(0, 1000);
if ($rand >= 100 && $rand <= 200)
$save[] = 'some string';
}
}
$save = implode(' ', $save);
This generates a random number and checks if it's between 100 and 200 inclusive and, if so, puts in the random string. You can change the range of the random number and that of the check to increase or decrease how many are added. You could also implement a counter to do something like make sure there are at least x
words between each string.
Again, this doesn't take into account punctuation or anything and just assumes all words are separated by spaces. So some fine tuning may be necessary to perfect it, but this should be a good starting point.