Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53392 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44454 invoked from network); 20 Jun 2011 12:06:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2011 12:06:01 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Linux 2.6 Received: from [82.113.146.227] ([82.113.146.227:48067] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C2/0C-34681-8A73FFD4 for ; Mon, 20 Jun 2011 08:06:01 -0400 Received: from localhost (xdebug.org [127.0.0.1]) by xdebug.org (Postfix) with ESMTPS id 72390DE13E; Mon, 20 Jun 2011 13:05:57 +0100 (BST) Date: Mon, 20 Jun 2011 13:05:57 +0100 (BST) X-X-Sender: derick@whisky To: Robert Eisele cc: internals@lists.php.net In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] Negative string offsets From: derick@php.net (Derick Rethans) On Mon, 20 Jun 2011, 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 Sounds like a good addition to me! For ArrayAccess, would this calculate the "correct" index so that current implementations of ArrayAccess don't have to be changed? cheers, Derick -- http://derickrethans.nl | http://xdebug.org Like Xdebug? Consider a donation: http://xdebug.org/donate.php twitter: @derickr and @xdebug