RE: [PHP-DEV] wordwrap confusion.

From: Date: Wed, 10 Oct 2001 23:03:50 +0000
Subject: RE: [PHP-DEV] wordwrap confusion.
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-67728@lists.php.net to get a copy of this message
Ok, since I didn't get much feedback (with the exception of Derick) I think this is how I am going to proceed with the wordwrap problems: width = 0 : Error out with appropriate message width > 0 : Cut lines at "width" characters. (Not including the break characters.) So: ----------------------------------------------------------- <?php wordwrap("this is my string", 1, "...\n", 1); ?> ----------------------------------------------------------- Will result in: t... h... i... s... ... i... s... ... m... y... ... s... t... r... i... n... g... If no one responds, I will assume its satisfactory. Thanks, Sean > -----Original Message----- > From: Sean R. Bright [mailto:elixer@erols.com] > Sent: Wednesday, October 10, 2001 6:24 AM > To: 'Derick Rethans' > Cc: 'PHP Developers Mailing List' > Subject: RE: [PHP-DEV] wordwrap confusion. > > > I don't think you understand what I mean. > > In my patch, if a width is specified that is 0 or less than 0, a > warning is printed and the width is defaulted to 75. You are right > when you say that the default is already 75, but that is when width > is not even specified. Also, 1 makes as much sense to me as 2 does > or greater does when "cut" is set to true. > > Sean > --------------------------------------------------------------------- > > -----Original Message----- > > From: Derick Rethans [mailto:derick@php.net] > > Sent: Wednesday, October 10, 2001 2:27 AM > > To: Sean R. Bright > > Cc: PHP Developers Mailing List > > Subject: Re: [PHP-DEV] wordwrap confusion. > > > > > > On Tue, 9 Oct 2001, Sean R. Bright wrote: > > > > > Ok. From the documentation for wordwrap(): > > > > > > Returns a string with str wrapped at the column number > > > specified by the (optional) width parameter. The line > > > is broken using the (optional) break parameter. > > > > > > The confusion lies with the phrase "column number" and the fact > > > that width values of <= 0 are allowed. This is what I have > > > noticed from a testing perspective: > > > > > > In all tests cut = 1 > > > width == 0 : crash > > > width == 1 : results in 2-character lines > > > width == 2 : results in 2-character lines > > > width > 2 : results in width-character lines > > > > > > I have a fix in hand for the case where width == 1, but I wanted > > > to get a concensus among the interested parties. I plan > to display > > > a warning for width values <= 0 and default to 75 as 0 > doesn't make > > > much sense. > > > > It does already do that, default to 75. And does it make any > > sense to have > > width be able to be 1? I don't think so, because it's even > > not possible. > > I'm +1 for denying widths smaller then 2, and then with an > > error, not a > > warning. > > > > Derick > > > > > --------------------------------------------------------------------- > > PHP: Scripting the Web - www.php.net - derick@php.net > > SRM: Site Resource Manager - www.vl-srm.net > > > --------------------------------------------------------------------- > > > > > > -- > > PHP Development Mailing List <http://www.php.net/> > > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > > For additional commands, e-mail: php-dev-help@lists.php.net > > To contact the list administrators, e-mail: > > php-list-admin@lists.php.net > > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net >

« previous php.dev (#67728) next »