2011/6/20 Derick Rethans <der...@php.net> > On Mon, 20 Jun 2011, Robert Eisele wrote: > > > Here is the next one. > > > > I think it's quite intuitive to use strtr() to remove single characters > of a > > string, too, instead of using many str_replace($str, $chr, ""). I'd glad > to > > see this change also in 5.4. > > Do you mean that (the currently documented): > > "If from and to have different lengths, the extra characters in the > longer of the two are ignored. The length of str will be the same as the > return value's." > > would then change into: > > "If from and to have different lengths, the extra characters in the > longer of the two are assumed to be the empty string, thus > removing those characters. The length of str will be the same as > the return value's unless the from and to have a different length." > > This could be one possible implementation. My implementation doesn't change the old behaviour of strtr(). I simply used the length of the "smaller" value to indicate what mode should get used; if the length is zero, all characters get removed like this:
$demise = strtr("passion", "os", ""); which results in "pain" > cheers, > Derick > Robert