note 26246 added to ref.strings

From: Date: Wed, 23 Oct 2002 21:30:38 +0000
Subject: note 26246 added to ref.strings
Groups: php.notes 
Request: Send a blank email to php-notes+get-38469@lists.php.net to get a copy of this message
If you are outputting to html, it might be better to insert a wordbreak (<wbr>) tag to allow a linebreak. If the text is too long and needs to be wrapped, the browser will break the line at that tag, otherwise, it ignores it. This is good because it won't even show up as a space if the browser doesn't wrap it at that point. Here's an optimised preg_replace version of the strmaxwordlen function that uses this tag: function splitLongWords($text, $max) {     return preg_replace( '/([^\s]{'.$max.'})(?=[^\s])/', '$1<wbr>', $text); } (note: I didn't test this thoroughly, it may need some work :) -- http://www.php.net/manual/en/ref.strings.php http://master.php.net/manage/user-notes.php?action=edit+26246 http://master.php.net/manage/user-notes.php?action=delete+26246 http://master.php.net/manage/user-notes.php?action=reject+26246

« previous php.notes (#38469) next »