note 82778 added to function.wordwrap
| From: | admin at jcink dot com | Date: | Fri, 25 Apr 2008 08:56:24 +0000 |
| Subject: | note 82778 added to function.wordwrap | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138766@lists.php.net to get a copy of this message | ||
I wanted something that would word wrap just one word. People were doing ffffffffffffffffff in my
comments page on my site, annoyingly stretching the page. but I didn't want to wrap at a
certain fixed length, just wanted to break up words like that only. Here's what I came up with
if anyone wants it.
function one_wordwrap($string,$width){
$s=explode(" ", $string);
foreach ($s as $k=>$v) {
$cnt=strlen($v);
if($cnt>$width) $v=wordwrap($v, $width, "<br />", true);
$new_string.="$v ";
}
return $new_string;
}
----
Server IP: 209.41.74.194
Probable Submitter: 67.81.196.235
----
Manual Page -- http://www.php.net/manual/en/function.wordwrap.php
Edit -- https://master.php.net/note/edit/82778
Del: integrated -- https://master.php.net/note/delete/82778/integrated
Del: useless -- https://master.php.net/note/delete/82778/useless
Del: bad code -- https://master.php.net/note/delete/82778/bad+code
Del: spam -- https://master.php.net/note/delete/82778/spam
Del: non-english -- https://master.php.net/note/delete/82778/non-english
Del: in docs -- https://master.php.net/note/delete/82778/in+docs
Del: other reasons-- https://master.php.net/note/delete/82778
Reject -- https://master.php.net/note/reject/82778
Search -- https://master.php.net/manage/user-notes.php