Re: str_pad() proposed changes
| From: | Matthew Leverton | Date: | Fri, 07 Jul 2000 20:36:15 +0000 |
| Subject: | Re: str_pad() proposed changes | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-5449@lists.php.net to get a copy of this message | ||
I never use the padding, although I use the trimming.
Couldn't you actually still add backwards compatibility (if necessary)
by adding a default case for the type if it is left blank?
It'd probably be sloppy, but something like:
string str_pad(string $str, int $x, int $type = NONE)
{
if ($type == NONE) {
// current string pad goes here
}
else {
// new string pad goes here
}
}
Or there could always be a new name for the function, like
string_pad().
--
Matthew Leverton - matthew@aeroinc.net -
http://www.allegro.cc
-----Original Message-----
From: Andrei Zmievski <andrei@ispi.net>
To: PHP List <php-general@lists.php.net>
Date: Friday, July 07, 2000 3:26 PM
Subject: [PHP] str_pad() proposed changes
>How many people use str_pad() function?
>
>I realized that currently it only pads on the left or on the right. I'd
>like to enhance it to be able to pad on both sides as well. It would
>look something like:
>
>$string = str_pad($string, 10, STR_PAD_RIGHT);
>$string = str_pad($string, 10, STR_PAD_LEFT);
>$string = str_pad($string, 10, STR_PAD_BOTH);
>
>Unfortunately, it's incompatible with the current version which looks
>like:
>
>$string = str_pad($string, 10);
>$string = str_pad($string, -10);
>
>So, that's why I wanted to know if I can go ahead and break it. The
>function isn't even documented yet..
>
>-Andrei
>
>The Heineken Uncertainty Principle:
> You can never be sure how many beers you had last night.
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
>