note 65150 added to function.wordwrap
| From: | barnet at gmx dot at | Date: | Tue, 25 Apr 2006 15:48:25 +0000 |
| Subject: | note 65150 added to function.wordwrap | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-109656@lists.php.net to get a copy of this message | ||
This works too (as an alternative):
<?php
function wrapit($text,$maxlength,$spacer)
{
$textarr=explode(" ",$text);
$i=0;
foreach($textarr as $textpart)
{
if (strlen($textpart) > $maxlength)$textarr[$i]= chunk_split($textpart,$maxlength,$spacer);
$i++;
}
$text=implode (" ",$textarr);
return $text;
}
?>
Instead of eg.
<?php
$comment=@wordwrap($comment, 52, " ", 1);
?>
simply write:
<?php
$comment=$wrapit($comment, 52, " ");
?>
----
Server IP: 217.13.201.10
Probable Submitter: 62.178.97.100
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.wordwrap.php
Edit -- http://master.php.net/note/edit/65150
Del: integrated -- http://master.php.net/note/delete/65150/integrated
Del: useless -- http://master.php.net/note/delete/65150/useless
Del: bad code -- http://master.php.net/note/delete/65150/bad+code
Del: spam -- http://master.php.net/note/delete/65150/spam
Del: non-english -- http://master.php.net/note/delete/65150/non-english
Del: in docs -- http://master.php.net/note/delete/65150/in+docs
Del: other reasons-- http://master.php.net/note/delete/65150
Reject -- http://master.php.net/note/reject/65150
Search -- http://master.php.net/manage/user-notes.php