Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53412 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94207 invoked from network); 20 Jun 2011 15:24:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2011 15:24:26 -0000 Authentication-Results: pb1.pair.com smtp.mail=ilia@prohost.org; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ilia@prohost.org; sender-id=pass Received-SPF: pass (pb1.pair.com: domain prohost.org designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: ilia@prohost.org X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:41698] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/94-34681-7266FFD4 for ; Mon, 20 Jun 2011 11:24:24 -0400 Received: by bwz18 with SMTP id 18so2842851bwz.29 for ; Mon, 20 Jun 2011 08:24:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.38.88 with SMTP id a24mr1698487bke.130.1308583459491; Mon, 20 Jun 2011 08:24:19 -0700 (PDT) Received: by 10.204.57.81 with HTTP; Mon, 20 Jun 2011 08:24:19 -0700 (PDT) In-Reply-To: References: Date: Mon, 20 Jun 2011 11:24:19 -0400 Message-ID: To: Robert Eisele Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Negative string offsets From: ilia@prohost.org (Ilia Alshanetsky) +1, seems useful. On Mon, Jun 20, 2011 at 8:02 AM, Robert Eisele wrote: > Negative string offsets is a wish and also an implementation of my running > PHP version for long. It operates in the same fashion like substr() with > negative offsets, but avoids the function call and is much smarter if one > single character has to be extracted: > > $str = "Hallo"; > > $str[0] == "H" > $str[-1] == "o"; > > If -6 is used as offset, the old warning is displayed because it's the first > undefined negative offset. > > The same thing for setting: > > $str[-1] = '0'; > $str[-4] = "4"; > > will result in "H4ll0" > > Would be glad to see this in 5.4 > > Robert >