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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2021 The PHP Group
All rights reserved.
Last updated: Sat Apr 17 22:01:30 2021 UTC