$counter = 0;
$insert_at = 160; // start at 160 chars into content
do {
$look_from = $insert_at = @strpos($content, ' ', $insert_at);
$before_opening_tag = strrpos($content, '<', $look_from);
$before_closing_tag = strrpos($content, '>', $look_from);
$after_opening_tag = strpos($content, '<', $look_from);
$after_closing_tag = strpos($content, '>', $look_from);
$counter++;
if ( $counter == 5) { break; }
} while (
($before_opening_tag > $before_closing_tag)
&&
($after_closing_tag < $after_opening_tag)
);
The while conditional should read like
"is the first closing tag less chars from beginning than an open tag?" (looks like: '<>SPACE')
AND
"is the first opening tag more chars after the next closing tag?" (looks like: 'SPACE<>')
overall I want this: "<img width="100" />SPACE<a href="">"
and not this: "<img width="100" /><aSPACEhref="">" or "<img width="100"SPACE/> <a href="">"
Edited by Allstar, 30 March 2012 - 03:30 PM.














