note 85753 added to function.wordwrap
| From: | php at maranelda dot org | Date: | Tue, 16 Sep 2008 11:17:19 +0000 |
| Subject: | note 85753 added to function.wordwrap | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-144443@lists.php.net to get a copy of this message | ||
Anyone attempting to write a text email client should be aware of the following:
<?php
$a = "some text that must wrap nice";
$a = wordwrap($a, 9);
echo $a;
// some text
// that must
// wrap nice
$a = wordwrap($a, 9);
echo $a;
// some text
// that
// must
// wrap
// nice
?>
Subsequent uses of wordwrap() on already wrapped text will take the end-of-line characters into
account when working out line length, thus reading each line that just fit nicely the first time
around as being one character too long the second. This can be a problem when preparing a text email
that contains (eg.) a forwarded email which has already been word-wrapped.
Solutions below which explode() the text on end-of-lines and wordwrap() the resulting strings
separately take care of this nicely.
----
Server IP: 92.48.100.16
Probable Submitter: 86.131.255.26
----
Manual Page -- http://www.php.net/manual/en/function.wordwrap.php
Edit -- https://master.php.net/note/edit/85753
Del: integrated -- https://master.php.net/note/delete/85753/integrated
Del: useless -- https://master.php.net/note/delete/85753/useless
Del: bad code -- https://master.php.net/note/delete/85753/bad+code
Del: spam -- https://master.php.net/note/delete/85753/spam
Del: non-english -- https://master.php.net/note/delete/85753/non-english
Del: in docs -- https://master.php.net/note/delete/85753/in+docs
Del: other reasons-- https://master.php.net/note/delete/85753
Reject -- https://master.php.net/note/reject/85753
Search -- https://master.php.net/manage/user-notes.php