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: 2016-06-07 16:29 UTC
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:0 of 1 (0.0%)
From: david71rj at gmail dot com Assigned:
Status: Open 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
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

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-07 16:29 UTC] cmb@php.net
Just for the record: that's called *slicing* in Python.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC