Re: [PHP-DEV] Fix for wordwrap()
[email protected] ("Ilia A.") Thu, 6 Mar 2003 09:53:22 -0500
| Newsgroups | php.dev |
|---|---|
| Organization | Prohost.org |
| Message-ID | <[email protected]> |
On March 6, 2003 06:52 am, Jedi/Sector One wrote: > Hello. > > Maybe this is the intended behavior, but wordwrap()'s behavior is a bit > illogical on PHP 4.3.1, as it does only break after a plain whitespace, not > after punctuation, \n, etc. > > Here's a trivial sample : > > $a = "wwwwwwwwwwwwwwwwww\nphprules\nwwwwwwwwwwwwwwwww"; > print wordwrap($a, 10, ' ', 10); > > Output : > > wwwwwwwwww wwwwwwww > p hprules > ww wwwwwwwwww wwwww > > The following trivial patch makes wordwrap() wrap after any > non-alphanumeric charater. Output after application of that patch : > > wwwwwwwwww wwwwwwww phprules wwwwwwwwww wwwwwww Seems like the expected behavior to me, you are hardcoding the 'break' as ' ', meaning that no other character is considered a space hence, \n are being treated as part of the string rather then a string separator. Ilia