Page 1 of 1

Breaking at a next sentence using substr(stripslashes(trim

Posted: Sun Jan 09, 2011 3:55 pm
by hantousha
I have a code see below:

Code: Select all

<b><?= stripslashes($newstitle)?></b><br><br />

<b><?= stripslashes($detrsltnewsrow['sourceagency'])?></b>&nbsp;- &nbsp;<?=$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> 

It inserts the tag
</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...

Re: Breaking at a next sentence using substr(stripslashes(tr

Posted: Fri Jan 14, 2011 11:47 am
by Jade
What you need to do is look for the first space, carriage return or punctuation mark starting from character 700. That will give you the end of the word without cutting it in the middle.