Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13667 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66238 invoked by uid 1010); 1 Nov 2004 15:06:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 66014 invoked from network); 1 Nov 2004 15:06:11 -0000 Received: from unknown (HELO iko.gotobg.net) (80.168.8.116) by pb1.pair.com with SMTP; 1 Nov 2004 15:06:11 -0000 Received: from pd9e613d0.dip.t-dialin.net ([217.230.19.208] helo=[192.168.0.6]) by iko.gotobg.net with esmtpa (Exim 4.43) id 1COdl7-0003A3-FC for internals@lists.php.net; Mon, 01 Nov 2004 17:06:13 +0200 Message-ID: <41865046.6040501@hristov.com> Date: Mon, 01 Nov 2004 16:03:34 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a4) Gecko/20040918 X-Accept-Language: en-us, en MIME-Version: 1.0 CC: internals@lists.php.net References: <418294D9.4070700@prohost.org> <20041029193421.9557.qmail@pb1.pair.com> <5.1.0.14.2.20041029162045.0439b9c0@localhost> <20041031093753.74166.qmail@pb1.pair.com> <42285846.20041031233522@marcus-boerger.de> <41856AEF.4060501@php.net> <4e89b426041031172932ada70f@mail.gmail.com> <1152524831.20041101030445@marcus-boerger.de> <24e5f3b7041031220372d44413@mail.gmail.com> <41864BCA.5050701@prohost.org> In-Reply-To: <41864BCA.5050701@prohost.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iko.gotobg.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] Re: Negative string offset support From: php@hristov.com (Andrey Hristov) just to mention that there is substr_replace() php -r '$a="abc"; var_dump(substr_replace($a, "d", -1));' IMO at least there is no need for range like $a{-4:2} Andrey Ilia Alshanetsky wrote: > IMO {-1} syntax is not only faster but simpler to use then the > equivalent substr() (for read) or $a[strlen($a) - 1] (for write). While > my reasons are primarily performance based, I think that most people > would find the {-1} simpler to use as well. > > Ilia > > Sterling Hughes wrote: > >> i hope not. this should be about what's cool for developers, the >> speed increase is not a compelling reason.. the debate is "does this >> make code easier to read/write/maintain?" I think it doesn't, and >> therefore am against it. >> >> -sterling >> >> >> On Mon, 1 Nov 2004 03:04:45 +0100, Marcus Boerger wrote: >> >>> Hello Wez, >>> >>> well it would. However 5.1 aims to be a major speed improvement and >>> that's >>> what the idea is about. >>> >>> best regards >>> marcus >>> >>> >>> >>> Monday, November 1, 2004, 2:29:46 AM, you wrote: >>> >>> >>>> Doesn't substr($a, -1) work ? >>> >>> >>>> --Wez. >>> >>> >>>> On Sun, 31 Oct 2004 17:45:03 -0500, Greg Beaver wrote: >>>> >>>>> It would reduce the errors I inevitably get >>>>> whenever using a complex feature like substr(). The three choices: >>>>> >>>>> 1) substr($a, strlen($a) - 1); >>>>> 2) $a{strlen($a) - 1} >>>>> 3) $a{-1} >>>>> >>>>> It's pretty obvious that the 3rd choice lowers the potential for all >>>>> kinds of bugs (mistypign, wrong parameter name, incorrect parameter >>>>> placement), and is much more readable. For those who already know how >>>>> {} works in PHP, it's also obvious what it does at the first look >>>>> without any speculation. >>> >>> >>> -- >>> Best regards, >>> Marcus mailto:helly@php.net >>> >>> -- >>> PHP Internals - PHP Runtime Development Mailing List >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >> >> >