Re: [PHP-DEV] Fix for wordwrap()

[email protected] (Tom Sommer) Sun, 9 Mar 2003 01:01:11 +0100
Newsgroups php.dev
Message-ID <[email protected]>
On Fri, 7 Mar 2003 08:20:19 +0100, Jedi/Sector One wrote:

> $a = "wwwwwwwwwwwwwwwwwwwwwwwww\nphprules\nwwwwwwwww";
> print wordwrap($a, 10, '<br />', 10);

>   Output :
>   
> wwwwwwwwww<br />wwwwwwwwww<br />wwwww
> phpr<br />ules
> wwwww<br />wwww

It's not....

it breaks with <br /> after 10 chars by force, because the cut argument is 
set

why have you set cut to 10?

as the documentation states, 
"If the cut is set to 1, the string is always wrapped at the specified 
width. So if you have a word that is larger than the given width, it is 
broken apart."

wordwrap is not broken...

It can be discussed if the cutcount (10) should be reset after a \n... 
which would be logic?

PS. cut should had been a boolean, IMHO :)
-- 
Tom Sommer, denmark
www.tsn.dk - www.dreamcoder.dk