Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53391 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42879 invoked from network); 20 Jun 2011 12:02:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2011 12:02:06 -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:58157] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CB/AB-34681-DB63FFD4 for ; Mon, 20 Jun 2011 08:02:05 -0400 Received: by vwl1 with SMTP id 1so1075273vwl.29 for ; Mon, 20 Jun 2011 05:02:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.220.189.13 with SMTP id dc13mr1757026vcb.169.1308571323119; Mon, 20 Jun 2011 05:02:03 -0700 (PDT) Received: by 10.220.45.196 with HTTP; Mon, 20 Jun 2011 05:02:03 -0700 (PDT) X-Originating-IP: [92.225.216.141] Date: Mon, 20 Jun 2011 14:02:03 +0200 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=90e6ba4fc3aee0b7f404a62380e2 Subject: Negative string offsets From: robert@xarg.org (Robert Eisele) --90e6ba4fc3aee0b7f404a62380e2 Content-Type: text/plain; charset=ISO-8859-1 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 --90e6ba4fc3aee0b7f404a62380e2--