Re: [PHP4BETA] replacing a substring
| From: | Lars Torben Wilson | Date: | Sat, 20 Nov 1999 22:40:09 +0000 |
| Subject: | Re: [PHP4BETA] replacing a substring | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-6601@lists.php.net to get a copy of this message | ||
Andrei Zmievski writes:
> On Wed, 17 Nov 1999, Lars Torben Wilson wrote:
> > May I propose a change in the argument order for substr_replace()? At
> > present, the argument list is:
> >
> > substr_replace($string, $start [, $length [, $repl]])
> >
> > The way it works now is effectively that if $length is not given,
> > neither may $repl be given, and nothing is done. It seems that this
> > order was chosen for its relationship to substr(). I think that it
> > might make more sense to go with a closer relationship to
> > str_replace(), and place the needle and the haystack closer
> > together. This would allow $length to be left out without affecting
> > $repl:
> >
> > substr_replace($string, $repl [, $start [, $length]])
> >
>
> Why do you have $start optional?
>
> -Andrei
Just because I figured that if a user is going to type
"substr_replace( $string, $repl, 0, 0 )", there doesn't seem to be any
real reason to make her type out the '0, 0' (or whatever $length would
default to). Basically, it boiled down to it being a case of making
slightly less typing in some cases, and not coming up with any great
reasons not to do it.
I'm not highly attached to the idea, however. :) I can see not making
$start optional, if only to add slightly more consistency to the
interface (which is lost again by $length being optional, but what the
hell ;) ).
So if there are reasons not to, that's cool.
Torben