note 58802 added to function.wordwrap

From: Date: Wed, 16 Nov 2005 14:17:50 +0000
Subject: note 58802 added to function.wordwrap
Groups: php.notes 
Request: Send a blank email to php-notes+get-98657@lists.php.net to get a copy of this message
Using wordwrap is usefull for formatting email-messages, but it has a disadvantage: line-breaks are often treated as whitespaces, resulting in odd behaviour including lines wrapped after just one word. To work around it I use this: <?php function linewrap($string, $width, $break, $cut) { $array = explode("\n", $string); $string = ""; foreach($array as $key => $val) { $string .= wordwrap($val, $width, $break, $cut); $string .= "\n"; } return $string; } ?> I then use linewrap() instead of wordwrap() hope this helps someone ---- Manual Page -- http://www.php.net/manual/en/function.wordwrap.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58802 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58802&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58802&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58802&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58802&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58802&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58802&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58802&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58802&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98657) next »