Forum Moderators: coopster
<b><?= stripslashes($newstitle)?></b><br><br />
<b><?= stripslashes($detrsltnewsrow['sourceagency'])?></b> - <?=$ndt?>
<br>
<?= substr(stripslashes(trim($detrsltnewsrow[news_desc])),0,701)?>
</td></tr>
<tr><td colspan="2" class="para" style="padding-left:10px;"><?= substr(stripslashes(trim($detrsltnewsrow[news_desc])),701)?></td></tr> </td></tr><tr><td colspan="2" class="para" style="padding-left:10px;">at the break of the 701 character. I want it to insert this at the end of a sentence at above 701 character of a description text. The way i have it it breaks the word if it hits the 701 character in the middle of the word. Will like it to insert the tags above at the next sentence after the 701 character. Any assistance.. will be appreciated...
$longstring = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque faucibus urna non velit elementum eu molestie quam posuere. In non risus sem, id convallis ligula. Proin felis erat, adipiscing vel dapibus tempus, gravida eu purus. Proin lacus eros, adipiscing cursus malesuada a, consectetur ac mi. Sed eros elit, commodo ut fermentum non, mattis ac mauris. Mauris a risus convallis est condimentum accumsan vitae sagittis erat. Maecenas vestibulum imperdiet vulputate. Donec sed quam sit amet velit malesuada tincidunt. Etiam auctor dignissim egestas. Aliquam sed neque eros. Vivamus tellus lorem, consectetur sit amet pellentesque in, porta venenatis tellus. Morbi vitae augue eget dui rhoncus gravida. Ut eget odio in lacus pharetra pellentesque.';
$out = preg_replace('/^(.{10}[^.]*).*/i','$1.',$longstring);
echo $out; // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
<?
$out = preg_replace('/^(.{701}[^.]*).*/i','$1.',$detrsltnewsrow[news_desc]);
echo $out;
?>
</td></tr>
<tr><td colspan="2" class="para" style="padding-left:10px;"><?= substr(stripslashes(trim($detrsltnewsrow[news_desc])),701)?></td></tr>
<?= substr(stripslashes(trim($detrsltnewsrow[news_desc])),701)?>
$longstring = 'First sentence. Second sentence. Third sentence.';
$out = preg_match('/^(.{10}[^.]*)(.*)/i', $longstring, $matches);
print_r($matches);