note 34666 deleted from function.wordwrap by aidan

From: Date: Mon, 19 Jul 2004 23:26:17 +0000
Subject: note 34666 deleted from function.wordwrap by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73651@lists.php.net to get a copy of this message
Note Submitter: corrupted_wise@yahoo.com ---- 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);

« previous php.notes (#73651) next »