Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13621 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36029 invoked by uid 1010); 30 Oct 2004 00:50:28 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 36004 invoked from network); 30 Oct 2004 00:50:28 -0000 Received: from unknown (HELO newweb.akbkhome.com) (202.81.246.113) by pb1.pair.com with SMTP; 30 Oct 2004 00:50:28 -0000 Received: from alanportable ([192.168.0.184]) by newweb.akbkhome.com with esmtp (Exim 4.33) id 1CNhRt-0002sK-Py; Sat, 30 Oct 2004 08:50:36 +0800 Message-ID: <4182E553.20801@akbkhome.com> Date: Sat, 30 Oct 2004 08:50:27 +0800 User-Agent: Mozilla Thunderbird 0.8 (X11/20040926) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ilia Alshanetsky CC: internals@lists.php.net References: <418294D9.4070700@prohost.org> In-Reply-To: <418294D9.4070700@prohost.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Negative string offset support From: alan@akbkhome.com (Alan Knowles) echo $a{strlen($a)-1}; ? is that really that bad. I do worry that at present $a = "a string"; $p = 0 while( $p < strlen($p) ) .. do stuff that could do $p-- or $p++ .... echo $a{$p}; } at present that would produce a nice error if you went < 0.. easy to spot.. - if -ve was supported it could do unexpected stuff.. Regards Alan Ilia Alshanetsky wrote: > I am wondering what are people's opinions on adding support for > negative string offsets that could be used to access data from the end > of a string. > > Ex. $a = "123"; echo $a[-1]; // would print 3 > > I don't think we should do this for arrays, since -1 and similar are > valid array keys, which means adding this support for arrays would > break BC. > > Ilia >