HTML attribute / url safe wordwrap function

From: Date: Tue, 04 Jan 2005 19:25:51 +0000
Subject: HTML attribute / url safe wordwrap function
Groups: php.general 
Request: Send a blank email to php-general+get-205620@lists.php.net to get a copy of this message
Howdy, Yes, I've googled - and yes, I've searched the archives - but didn't find a solution for my problem. Here's the deal: On a website ppl can react on articles and post messages. The content of a message is given to a function which parses it all, taking care of long "words" which could mess up the interface. Or actually - it does do that. It all wraps perfectly fine with the following lines of code: <?php $txt = 'website ppl can react on articles <a href="http://aspn.activestate.com/ASPN/docs/PHP/function.wordwrap.html">wordwrap</a>'; $txt = preg_replace('#(<a.*>)((http|ftp|www).{13})(.*)(.{20})(</a>)#U', ' $1$2(...)$5$6 ', $txt); $txt = preg_replace('/([\.\?\w\)\(\:\',!\-\=]{30})/', '$1 ', $txt); ?> Unfortunately, this also breaks the weblink address. So, some wordwrapping function that doesn't do that would be cool. So far, I haven't been able to find it or create it myself. Somebody out there feels like giving it a shot? Thanks, Wouter

« previous php.general (#205620) next »