Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53408 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81782 invoked from network); 20 Jun 2011 14:31:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2011 14:31:12 -0000 Authentication-Results: pb1.pair.com header.from=ekneuss@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=ekneuss@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: ekneuss@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:53417] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E3/92-34681-EA95FFD4 for ; Mon, 20 Jun 2011 10:31:10 -0400 Received: by bwz18 with SMTP id 18so2795771bwz.29 for ; Mon, 20 Jun 2011 07:31:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=PjGEi9BbAkpNXuwySu5r9dsu/QaCZNRhKfEr2mmzFXA=; b=h2UVAI+8I4Cl94xMI+5S5SCs2d2CURv7w1v6B8rfi1Q47GPXAQnLddYEhquUM6Szyr syV+ctQLqu7NJfreFImDVDPgd0ob6MKFYX2QyVKx785r9XHGfMmLGvfCLznXBAzq3DR7 829TVv90g8k5aqhRoG680dHmsHzbOtpQw+egE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=QkCKwXeABzLQlUbRwRXjHqrB07wAFebYHDqt15lK30EoVQcpwI2n14Hr+Qkk87qWiP rmJKgJ7/0fX50gjr52kYBwokRkLAxjxP7bjOzbzQLJZHgFQlz8j0mtHjHGlJBN82bQt7 3yKq2Oap50g7Qcs0iiKDiNcJsSrNA+NyqIntE= MIME-Version: 1.0 Received: by 10.204.46.161 with SMTP id j33mr4020355bkf.212.1308580267044; Mon, 20 Jun 2011 07:31:07 -0700 (PDT) Sender: ekneuss@gmail.com Received: by 10.204.10.66 with HTTP; Mon, 20 Jun 2011 07:31:06 -0700 (PDT) In-Reply-To: References: Date: Mon, 20 Jun 2011 16:31:06 +0200 X-Google-Sender-Auth: s7L8CHLlSXcMsjn2u5YvqNAN9ro Message-ID: To: Derick Rethans Cc: Robert Eisele , internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Negative string offsets From: colder@php.net (Etienne Kneuss) Hi, On Mon, Jun 20, 2011 at 14:05, Derick Rethans wrote: > 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? Do you mean ArrayObject? ArrayAccess is the interface. Regardless, I don't believe it makes sense to change the semantics of those indexes for arrays, since arrays can define negative indexes. i.e. $a = array(-1 => "foo", 2 => "bar"); $a[-1] should really be "foo", and not "bar". This looks useful for strings though! > > cheers, > Derick > > -- > http://derickrethans.nl | http://xdebug.org > Like Xdebug? Consider a donation: http://xdebug.org/donate.php > twitter: @derickr and @xdebug > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Etienne Kneuss http://www.colder.ch