Re: Fix for wordwrap()

From: Date: Thu, 06 Mar 2003 14:53:22 +0000
Subject: Re: Fix for wordwrap()
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-94867@lists.php.net to get a copy of this message
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

« previous php.dev (#94867) next »