|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52129 Easy substr/array_splice method
Submitted: 2010-06-20 21:39 UTC Modified: 2018-04-08 15:07 UTC
Avg. Score:2.0 ± 1.0
Reproduced:0 of 1 (0.0%)
From: david71rj at gmail dot com Assigned:
Status: Suspended Package: Strings related
PHP Version: 5.3.2 OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-06-20 21:39 UTC] david71rj at gmail dot com
In python exists a easy method for substr, and I suggest this for PHP. I think 
that not will do incompatible nothing because is a new method.

$test = "Hello";
echo $test[0]; // Exists: H
echo $test[0, 1; // New: H (too)
echo $test[-1]; // New: o
echo $test[-3]; // New: llo

$test = array(0, 1, 2);
echo $test[0]; // 0
echo $test[0, 2]; // array(0, 1, 2)

In python is [x:y], but in PHP I thinkg think that is better ',' to don't 



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-07 16:29 UTC]
Just for the record: that's called *slicing* in Python.
 [2018-04-08 15:07 UTC]
-Status: Open +Status: Suspended
 [2018-04-08 15:07 UTC]
Because this feature would require to change the syntax of PHP, it
would require the RFC process[1].  Anybody is welcome to start it!
For the time being, I'm suspending this ticket.

[1] <>
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Oct 20 17:03:35 2021 UTC