|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7076 Incosistence between explode and implode
Submitted: 2000-10-07 03:47 UTC Modified: 2000-10-07 06:01 UTC
From: v at w dot cl Assigned:
Status: Closed Package: *Function Specific
PHP Version: 4.0.3RC2 OS: RedHat 6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: v at w dot cl
New email:
PHP Version: OS:


 [2000-10-07 03:47 UTC] v at w dot cl
Implode and explode can behave differently.

I can write 


and $a would be the expected string separated by |.

But if I write 


$array would NOT be the original $array, but an empty value.

And neither implode or explode throws a warning about the bad parameter passing.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-07 06:01 UTC]
This is actually the correct behaviour. 
implode() can accept its two arguments in any order: the array first, 
or the string. This is possible because it can examine each argument 
to discern which is which based on type. explode() can't do that, 
since it can accept only strings. Essentially, by writing 'explode($a, 
"|")', you are telling PHP to split the string "|" on each occurrence 
of $a within it. To us this is obviously likely to not be what you 
wanted, but to PHP it makes sense--it trusts that this is what you 
want to do, and so it tries it and returns the result: an array 
containing only "|". 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue May 21 00:01:27 2019 UTC