note 53403 added to function.wordwrap
| From: | Kyle at osu1 dot php dot net | Date: | Tue, 31 May 2005 18:34:57 +0000 |
| Subject: | note 53403 added to function.wordwrap | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-89703@lists.php.net to get a copy of this message | ||
Yet-another-wordwrap-improvement... If you attempt to wordwrap() lines that already contain some
line-breaks that you want to maintain, a simple wrapper around wordwrap can help. For example:
function preserve_wordwrap($tstr, $len = 75, $br = '\n') {
$strs = explode($tstr,$br);
$retstr = "";
foreach ($strs as $str) {
$retstr .= wordwrap($str,$len,$br) . $br;
}
return $retstr;
}
I used a function like this for pulling quotes for my email out of a mysql database and formatting
them for use in an email. Some quotes had multiple lines (e.g. a short conversation-style quote)
that I wanted to maintain yet still word-wrap correctly.
----
Manual Page -- http://www.php.net/manual/en/function.wordwrap.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53403
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53403&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53403&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53403&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53403&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53403&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53403&report=yes
Search -- http://master.php.net/manage/user-notes.php