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 (profile)
Status: Closed Package: Strings related
PHP Version: * OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
8 + 23 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC