I am trying to write a blog system. The main page is consist of part of the content of blog entries.
The problem is how could I make sure the excerpt is truncated correctly, since the blog entries is stored in HTML code.
Thanks.
I am trying to write a blog system. The main page is consist of part of the content of blog entries.
The problem is how could I make sure the excerpt is truncated correctly, since the blog entries is stored in HTML code.
Thanks.
Your best bet would be to use strip_tags()
to remove the HTML from it and show only the first 300 or so characters using substr
. Otherwise you'd have to parse the HTML to break it at an appropriate place so as not to break the rest of your layout.