Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53385 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32753 invoked from network); 20 Jun 2011 11:32:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2011 11:32:36 -0000 Authentication-Results: pb1.pair.com header.from=robert@xarg.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=robert@xarg.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain xarg.org from 209.85.212.42 cause and error) X-PHP-List-Original-Sender: robert@xarg.org X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:55055] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/A9-34681-3DF2FFD4 for ; Mon, 20 Jun 2011 07:32:35 -0400 Received: by vwl1 with SMTP id 1so1058553vwl.29 for ; Mon, 20 Jun 2011 04:32:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.99.83 with SMTP id t19mr784559vcn.204.1308569550115; Mon, 20 Jun 2011 04:32:30 -0700 (PDT) Received: by 10.220.45.196 with HTTP; Mon, 20 Jun 2011 04:32:30 -0700 (PDT) X-Originating-IP: [92.225.216.141] In-Reply-To: References: Date: Mon, 20 Jun 2011 13:32:30 +0200 Message-ID: To: Derick Rethans Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=0016e646a3c232d4fe04a6231747 Subject: Re: [PHP-DEV] Changed behaviour for strtr() From: robert@xarg.org (Robert Eisele) --0016e646a3c232d4fe04a6231747 Content-Type: text/plain; charset=ISO-8859-1 2011/6/20 Derick Rethans > 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 --0016e646a3c232d4fe04a6231747--