Req #50649 [Asn->Csd]: negative offsets for strings

From: Date: Mon, 07 Mar 2016 11:54:36 +0000
Subject: Req #50649 [Asn->Csd]: negative offsets for strings
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199645@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=50649&edit=1 ID: 50649 Updated by: francois@php.net Reported by: robert_xp at gmx dot net Summary: negative offsets for strings -Status: Assigned +Status: Closed Type: Feature/Change Request Package: Scripting Engine problem Operating System: * PHP Version: * Assigned To: francois Block user comment: N Private report: N New Comment: The fix for this bug has been committed. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. Implemented in version 7.1 Previous Comments: ------------------------------------------------------------------------ [2010-01-04 16:15:41] aharvey@php.net For reference, functionality similar to this has been discussed at least once before on the Internals mailing list: http://marc.info/?l=php-internals&m=119123827510426&w=2 I'm not going to Won't Fix this, because unlike bug #50647, this hasn't been denied via the RFC process. I'd suggest that writing an RFC to start a discussion on Internals is probably the right way to go about this (being a language change), rather than a feature request here. ------------------------------------------------------------------------ [2010-01-04 11:55:48] robert_xp at gmx dot net Description: ------------ I heared somewhere, that string offsets will be removed in future releases of PHP, as of 6.0. I like accessing single characters in a C/C++ like way. If you pass a negative offset to strings, it would be a good improvement to start at the end of the string, like the behavior of substr(). The same is also possible for arrays, but I only focused on string offsets here: http://www.xarg.org/2009/12/php-hacking/ Reproduce code: --------------- $str = "Hello"; echo $str[-2].$str[-1].$str[0]; Expected result: ---------------- loH Actual result: -------------- Warnings ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=50649&edit=1

« previous php.bugs (#199645) next »