Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73724 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71146 invoked from network); 17 Apr 2014 15:33:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Apr 2014 15:33:27 -0000 Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 78.32.209.33 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 78.32.209.33 freshmint.phcomp.co.uk Received: from [78.32.209.33] ([78.32.209.33:49004] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/E4-39661-544FF435 for ; Thu, 17 Apr 2014 11:33:26 -0400 Received: from addw by mint.phcomp.co.uk with local (Exim 4.72) (envelope-from ) id 1WaoJW-0001X2-BZ for internals@lists.php.net; Thu, 17 Apr 2014 16:33:22 +0100 Date: Thu, 17 Apr 2014 16:33:22 +0100 To: internals@lists.php.net Message-ID: <20140417153322.GV5587@phcomp.co.uk> Mail-Followup-To: internals@lists.php.net References: <1397744009.2829.3212.camel@guybrush> <1397747255.2829.3225.camel@guybrush> <534FF26E.6070602@lerdorf.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <534FF26E.6070602@lerdorf.com> Organization: Parliament Hill Computers Ltd User-Agent: Mutt/1.5.20 (2009-12-10) Subject: Re: [PHP-DEV] Negative string offsets From: addw@phcomp.co.uk (Alain Williams) On Thu, Apr 17, 2014 at 08:25:34AM -0700, Rasmus Lerdorf wrote: > Yeah, it wouldn't make any sense unless it supported ranges. Something like: > > if($filename[-4,4] === '.ext') ... > > although, I don't see how that is better than: > > if(substr($filename,-4) === '.ext') ... > > The latter is much clearer. Clarity depends on what you are used to. Once that was in the language and had been used a few times - you would just read it. Looking at your example of rangs (or slices) checking the last bit of a string would be nicer if you could omit the length to do exactly what you example above does: if($filename[-4,] === '.ext') ... -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include