note 34666 added to function.wordwrap

From: Date: Sun, 03 Aug 2003 08:19:21 +0000
Subject: note 34666 added to function.wordwrap
Groups: php.notes 
Request: Send a blank email to php-notes+get-53233@lists.php.net to get a copy of this message
wordwrap() will parse through html tags, which can be a problem, url's for example. <a href="http://www.somelinkouttherethatgoestoawebsite.com/"> somelinkouttherethatgoestoawebsite</a> if you do a wordwrap($thatstring, 10, '<br />', 1) you'll get <a> href="http ://www.som elinkoutth erethatgoe stoawebsit e.com/">so melinkoutt herethatgo estoawebsi te</a> I know no might use 10, but it's an example, and will screw up the link. A clutch i have made bypasses all tags to properly wrap the message. $wrap_at = 45; $string = preg_replace('%(\s*)([^>]{'.$wrap_at.',})(<|$)%e', "'\\1'.wordwrap('\\2', '".$wrap_at."', '<br />', 1).'\\3'", $string); ---- Manual Page -- http://www.php.net/manual/en/function.wordwrap.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34666 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34666&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34666&report=yes

« previous php.notes (#53233) next »