Reputation: 23
I have a codeigniter page that displays the first 16 words of a product's description from a database. Users can change the description to include i tags and b tags using CKEditor. The problem is that when I truncate the description to 16 words I lose the closing /i and /b tags and that causes my application to malfunction in multiple ways.
My existing code that displays the description.
<p><?php echo word_limiter($product['description'], 16); ?></p>
What would be the best way to automatically close the formatting tags that could be included in the description?
Upvotes: 2
Views: 134
Reputation: 3476
You need to use strip_tags
so that it will remove all HTML tags before rendering.
<p><?php echo strip_tags( word_limiter($product['description'], 16) ); ?></p>
Upvotes: 1