substr(); to chop an entry
Posted: Fri Feb 13, 2004 4:46 am
Hello,
I've written myself a blog system, and on a page I want to display the first part of a blog entry.
Currently I'm usingTo chop the first 2000 characters from the entry and display them, however, some of the entries will contain links and images, and if they are around the 2000 characters mark the html might get chopped and screw everything up, example:
<img src="/im
<a href="http://ww
(The links are stored in the database using bbcode
and moo.com is great which is then changed to html when it's grabbed from the database, if this makes any difference.)
Is there some way to get php to chop the entry to around about 2000 characters, if the 2000th character falls in the middle of an image or link then it will chop at the end of the image or link or the begining of it instead of part way through.
Hope you guys understand what I'm trying to do
Any help would be great.
I've written myself a blog system, and on a page I want to display the first part of a blog entry.
Currently I'm using
Code: Select all
$entry = substr($row[entry], 0, 2000);<img src="/im
<a href="http://ww
(The links are stored in the database using bbcode
Is there some way to get php to chop the entry to around about 2000 characters, if the 2000th character falls in the middle of an image or link then it will chop at the end of the image or link or the begining of it instead of part way through.
Hope you guys understand what I'm trying to do
Any help would be great.