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.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to