You could also try a combination of html_entity_decode to change all
entities back, then truncate it, then use html_entities to get back to
the encoded string.
Hope this helps
Cherrs
Chris
Robert Cummings wrote:
On Mon, 2004-10-18 at 14:35, Murray @ PlanetThoughtful wrote:
Hi All,
I'm working on a page where I'm attempting to display article titles in a
relatively narrow area. To save from ugly wrap-arounds in the links, I've
decided to truncate the article title string at 20 chars. This works well
except where the truncate occasionally falls in the middle of a HTML entity
reference (eg or © etc).
after you do your usual truncation just add the following:
$truncated = ereg_replace( '&[[:alpha:]]*$', '', $truncated );
You may need to replace alpha with alnum since I can't remember if there
are any entities with digits :)
Cheers,
Rob.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php