You could split the article on sentences ( . ). Output n sentences, output your banner, output the rest.
PHP Code:
$test = "Sentence 1. Sentence 2. Sentence 3. Sentence 4.";
$sentences = explode(". ", $test);
$banner = "I'm only here for the beer. ";
// line of dbg, rm this
var_dump($sentences);
$first = array_slice($sentences,0 ,2);
$last = array_slice($sentences, 2);
$output = join(". ",$first) . '. ';
$output .= $banner;
$output .= join(". ", $last);
echo $output;
//gives:
// some debug, see whats going on
array
0 => string 'Sentence 1' (length=10)
1 => string 'Sentence 2' (length=10)
2 => string 'Sentence 3' (length=10)
3 => string 'Sentence 4.' (length=11)
// your sentences with an advert in them
Sentence 1. Sentence 2. I'm only here for the beer. Sentence 3. Sentence 4.
Bookmarks