Hi all,
Here`s a problem I have been working on for a while, but can`t seem to
solve satisfactory.
I have a database with blog entries. Because each of those entries has a
variable length which can be quite long, I want to build an overview page.
Of each entry there will be a preview version, say 700 characters max.
My problem has to do with HTML tags. If for example an entry contains a
<BLOCKQUOTE> with a large quote, my function would break off somewhere
halfway in the quote. The end result of course won`t have the
</BLOCKQUOTE>, rendering the resulting page horribly bad.
I would like to build a function that breaks a string up to max X
characters long, but plays it safe when it encounters any HTML tag: it
does not matter if the end result is a string of say 670 characters long,
it only matters that it approximates the max character setting and doesn`t
mess up the HTML tags.
Can anyone point me in the right direction?
Hans