php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #36524 Negative indexes in strings
Submitted: 2006-02-25 06:55 UTC Modified: 2016-03-07 11:52 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: terrafrost at gmail dot com Assigned: francois
Status: Closed Package: Strings related
PHP Version: * OS: *
Private report: No CVE-ID:
 [2006-02-25 06:55 UTC] terrafrost at gmail dot com
Description:
------------
Currently, in PHP, if you want to reference the last character of a string, you'd need to do something like $x{strlen($x)-1}.  If using substr, however, you can do substr($x,-1,1) or substr($x,strlen($x)-1,1).  In keeping with the former substr example, $x{-1} could be made to access the last character of a string as well.  Since, right now, using negative numbers will result in a warning, it seems unlikely that any existing code is going to be broken by such a change...


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-02-25 17:24 UTC] derick@php.net
This is planned for PHP 6:
http://www.php.net/~derick/meeting-notes.html#cleanup-for-vs

 [2015-01-09 00:12 UTC] ajf@php.net
-Package: Feature/Change Request +Package: *General Issues -Operating System: any +Operating System: * -PHP Version: 4.4.2 +PHP Version: *
 [2015-01-09 00:12 UTC] ajf@php.net
PHP 6 was scrapped.

Will this happen eventually?
 [2015-01-09 00:13 UTC] ajf@php.net
-Package: *General Issues +Package: Strings related
 [2016-01-04 17:36 UTC] francois@php.net
-Assigned To: +Assigned To: francois
 [2016-03-07 11:52 UTC] francois@php.net
-Status: Assigned +Status: Closed
 [2016-03-07 11:52 UTC] francois@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

Implemented in version 7.1
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Tue Aug 29 15:01:52 2017 UTC