|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 21:00:01 2025 UTC |
use preg_split instead ;) var_dump(preg_split('/[, !\.]/', 'Hello, World! This is a Test!'));