note 36594 added to function.wordwrap

From: Date: Wed, 15 Oct 2003 19:53:11 +0000
Subject: note 36594 added to function.wordwrap
Groups: php.notes 
Request: Send a blank email to php-notes+get-58661@lists.php.net to get a copy of this message
Discovered that wordwrap doesnt care about "\r\n" that are already there when wrapping so output can be somewhat strange. Some comments in Swedish, sorry for that ;) function ww ($sInput, $iW = 100) { /* ww 1.0 <tomasz@codestar.se> Created 2003-10-15 Wordwraps input string considering already existing newlines. Returns wrapped string with newlines in "\r\n"-format. $sInput The string to be wrapped $iW Max number of chars in each row */ /* Splitta i delar efter nuvarande radbrytningar i "\r\n"-format */ $aInput = split ("\r\n", $sInput); /* Splitta i ytterligare delar efter nuvarande "\n"-brytningar */ foreach ( $aInput as $aPiece ) { $aAdd = split ("\n", $aPiece); foreach ( $aAdd as $sAddPiece ) { $aNewInput[] = $sAddPiece; } } $aInput = $aNewInput; /* Skapa retursträng utifrån alla bitar av insträngen, wrappa varje vit för sig */ foreach ( $aInput as $sPiece ) { $sO .= wordwrap ($sPiece, $iW, "\r\n") . "\r\n"; } return $sO; } ---- Manual Page -- http://www.php.net/manual/en/function.wordwrap.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36594 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36594&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36594&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#58661) next »