php.net |  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
Votes:2
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: david71rj at gmail dot com
New email:
PHP Version: OS:

 

 [2010-06-20 21:39 UTC] david71rj at gmail dot com
Description:
------------
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 
complicate.

Bye.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-07 16:29 UTC] cmb@php.net
Just for the record: that's called *slicing* in Python.
 [2018-04-08 15:07 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2018-04-08 15:07 UTC] cmb@php.net
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] <https://wiki.php.net/rfc/howto>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC