Re: [PHP4BETA] replacing a substring
| From: | Lars Torben Wilson | Date: | Thu, 18 Nov 1999 04:13:05 +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-6422@lists.php.net to get a copy of this message | ||
Andrei Zmievski writes:
> The reason I did it is that people may want to omit the $repl,
> effectively having substr_replace() remove a chunk of the string. I am
> pretty flexible abou this, I just don't know how many people want it one
> way or the other.
Yeah, neither do I. With the diffs I sent, you can achieve this by
using the empty string for $repl. I'm just going by the fact that when
I personally tried it and started writing the docs, it felt a little
cumbersome. But one data point does not make much of a case study into
what users want. :)
> > Now, with this idea, the only problem is what $length should default
> > to. Personally, I like it defaulting to 0, which just inserts $repl
> > into $string at $start. However, it would be more consistent with
> > substr() if $length defaulted to strlen( $string ), which would result
> > in everything from $start to the end of $string being replaced. Come
> > to think of if, perhaps strlen( $repl ) would make more sense.
>
> Right now it defaults to the value that would remove anythin from the
> offset to the end of the string. Once again, different people have
> different opinions on what should be the default. I don't know exactly
> how to gauge it.
Again, me neither. Maybe there should be a definitive list somewhere:
"How to Make Everyone Happy". The people talking about db abstraction
could probably use something like that, too...
Torben