Category: >> PHP Code >> Truncate text while preserving HTML tags Bookmark and Share

<< lastnext >>

Snippet Name: Truncate text while preserving HTML tags

Description: Truncate or limit a text string while still preserving any HTML tags present. The code auto-closes the tags.

Also see:
» Fastest javascript Trim() function
» Javascript Trim Functions
» Convert text to image in php
» BR2NL Function - Opposite of NL2BR
» Neatly trim a string to a set numb...
» Truncate Links Over X Chars long
» String Functions: LTRIM
» String Functions: RTRIM
» Number Functions: Truncate to n
» Number Functions: Truncate
» Improved Strip_Tags()
» Get text between tags
» Convert BBCode Tags

Comment: (none)

Author: CoderZone
Language: PHP
Highlight Mode: PHP
Last Modified: May 27th, 2010

echo String::truncate('jo<i><b>n</b>as</i>', 3, '...'); //jo<...
echo String::truncate('jo<i><b>n</b>as</i>', 3, '...', true); //jo<i><b>n</b></i>...
echo String::truncate('jo<i><b>n</b>as</i>', 3, '...', true, false); //jo<i><b>n...
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© | users online: 6