php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50653 str_split sequence handling
Submitted: 2010-01-04 12:22 UTC Modified: 2010-12-20 15:53 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: robert_xp at gmx dot net Assigned:
Status: Open Package: Strings related
PHP Version: 5.3.1 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: robert_xp at gmx dot net
New email:
PHP Version: OS:

 

 [2010-01-04 12:22 UTC] robert_xp at gmx dot net
Description:
------------
str_split is only able to split a string in periodical substrings. I think, it's a good improvement to allow arrays as a second parameter to handle sequences. I wrote a patch for that: http://www.xarg.org/2009/12/php-hacking/

Reproduce code:
---------------
var_dump(str_split("0123456789abcdefwant to extract this?abcd", array(16, -4)));

var_dump(str_split("hello how are you?", array(0, 1, 6, 7, 9, -2, -1)));


Expected result:
----------------
array(3) {
  [0]=>
  string(16) "0123456789abcdef"
  [1]=>
  string(21) "want to extract this?"
  [2]=>
  string(4) "abcd"
}
array(7) {
  [0]=>
  string(1) "h"
  [1]=>
  string(5) "ello "
  [2]=>
  string(1) "h"
  [3]=>
  string(2) "ow"
  [4]=>
  string(7) " are yo"
  [5]=>
  string(1) "u"
  [6]=>
  string(1) "?"
}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-20 15:53 UTC] jani@php.net
-Package: Feature/Change Request +Package: Strings related
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC