Php Function For Text Formatting

I need simple changes to a PHP function that shortens the text from a blog posting into a few sentences and places ‘ […]’ instead of the period at the end.

I need it to:

Check if the blog post was actually shortened. Only if it is will the ‘ […]’ be added to the end. If not, the period will remain.

Return correctly HTML formatted text if possible. The function currently strips all tags which I do not like. I want it to keep the valid XHTML that is in the post such as bold, italics, ordered lists, ect – I don’t want missing ending tags after the posting is shortened.

Have a feature that will break the shortened version by inserting hidden HTML codes into the post. For instance, I would like to specify certain posts that are shortened only when an HTML comment that contains the word ‘BREAK’ is found.

The current function is attached. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *