PHP 4.0 Bug #7076 Updated: Incosistence between explode and implode
| From: | Bug Database | Date: | Sat, 07 Oct 2000 10:01:26 +0000 |
| Subject: | PHP 4.0 Bug #7076 Updated: Incosistence between explode and implode | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-34430@lists.php.net to get a copy of this message | ||
ID: 7076
Updated by: torben
Reported By: v@w.cl
Status: Closed
Bug Type: *Function Specific
Assigned To:
Comments:
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 "|".
Previous Comments:
---------------------------------------------------------------------------
[2000-10-07 03:47:28] v@w.cl
Implode and explode can behave differently.
I can write
$a=implode($array,"|");
and $a would be the expected string separated by |.
But if I write
$array=explode($a,"|");
$array would NOT be the original $array, but an empty value.
And neither implode or explode throws a warning about the bad parameter passing.
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=7076