Newbie help with substr - limit without breaking words
Posted: Mon Aug 03, 2009 7:45 am
Hi all, I'm a newbie working with PHP - so PLEASE be gentle!
I need to limit the amount of information displayed when viewing results then being taken to a READ MORE link for the full story
i.e "My news story goes here . . . READ MORE"
I am currently using
<?php echo substr ($row_news['title'],0,40); ?>
which nicely limits the displayed characters to 40.
Unfortunately, it breaks in the middle of words - which looks terrible.
How do I return these limited results without breaking complete words in the middle?
Have looked for answers elsewhere, but am presented with pages of code, with no indication of what to do with it!
Many thanks for any help
I need to limit the amount of information displayed when viewing results then being taken to a READ MORE link for the full story
i.e "My news story goes here . . . READ MORE"
I am currently using
<?php echo substr ($row_news['title'],0,40); ?>
which nicely limits the displayed characters to 40.
Unfortunately, it breaks in the middle of words - which looks terrible.
How do I return these limited results without breaking complete words in the middle?
Have looked for answers elsewhere, but am presented with pages of code, with no indication of what to do with it!
Many thanks for any help