php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52268 explode with an Array as Delimiter
Submitted: 2010-07-06 20:28 UTC Modified: 2010-12-01 15:34 UTC
From: halloanjedendenichkenne at gmail dot com Assigned:
Status: Wont fix Package: Arrays related
PHP Version: Irrelevant OS: Irrelevant
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: halloanjedendenichkenne at gmail dot com
New email:
PHP Version: OS:

 

 [2010-07-06 20:28 UTC] halloanjedendenichkenne at gmail dot com
Description:
------------
It would be useful if you were able to pass an Array as Delimiter to explode.
The "Test Script" contains an Example.

Test script:
---------------
<?php

  var_dump(explode(array(',', '.', '!', ' '), 'Hello, World! This is a Test!'));
  /*

    Should output something like:
      array(8) {
        [0]=>
        string(5) "Hello"
        [1]=>
        string(0) ""
        [2]=>
        string(5) "World"
        [3]=>
        string(0) ""
        [4]=>
        string(4) "This"
        [5]=>
        string(2) "is"
        [6]=>
        string(1) "a"
        [7]=>
        string(4) "Test"
      }

  */

?>

Expected result:
----------------
Included in the Test Script

Actual result:
--------------
Warning: explode() expects parameter 1 to be string, array given in php shell code 
on line 1
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-11 01:17 UTC] jinmoku at hotmail dot com
use preg_split instead ;)

var_dump(preg_split('/[, !\.]/', 'Hello, World! This is a Test!'));
 [2010-12-01 15:34 UTC] jani@php.net
-Status: Open +Status: Wont fix -Package: Unknown/Other Function +Package: Arrays related
 [2010-12-01 15:34 UTC] jani@php.net
See above.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 19:01:30 2024 UTC