ID:               22226
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Bogus
 Bug Type:         Scripting Engine problem
 Operating System: Win32
 PHP Version:      4.2.1
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

"" is not NULL, which in this case would work the same anyway because
the function expects you to pass 2 strings, the separator & the string
to break. Therefor any values passed to the function will 1st be
converted to strings meaning that you can never get anything but an
array with atleast 1 element as the return value.
If you want to validate the string manually use the empty() function
before calling explode(). Altering the behaviour of this function would
result in breaking of backwards compatibility and is not an option.


Previous Comments:
------------------------------------------------------------------------

[2003-02-15 13:15:18] [EMAIL PROTECTED]

Thanks for the reply. I understand that it is intended that, if the
separator string cannot be found, the entire contents of the string
will be stored in the 1st element of the returned array. This makes
perfect sense, if there IS a contents. But if there is no contents
because the string is empty, this is not the behaviour one would
expect.

Now why do I expect a different behaviour? Let's use a http get parm as
an obvious example: 

explode("&", "a=b&x=y") returns array("a=b", "x=y")
I expect this of course.

explode("&", "a=b")     returns array("a=b")
Same here. I have a get parm, I get an array entry.

explode("&", "")        returns array("")
But here? I have nothing but nonetheless an array entry is returned?
This means I have to pre-check the string for the special case of an
empty string since usually this means "no data", "no parm", "no
entry".

BTW, explode returns a one element array even if it explodes NULL
instead of an empty string. Now that is strange, isn't it?

I re-opened the bug but won't bother you any more if you insist to put
it back to bogus once more. Thanks fo your time.

------------------------------------------------------------------------

[2003-02-15 11:04:05] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

If the separator string cannot be found the entire contents of the
passed string will be stored in the 1st element of the returned array.
This is intended behaviour.

------------------------------------------------------------------------

[2003-02-14 16:47:13] [EMAIL PROTECTED]

This was reported before (bug #8883) as 

count(explode("|", "")) == 1

but was stated bogus for some unexplained reason.

The problem is: exploding an empty string returns an array with one
empty element, but should return an empty array instead. 

I found this bug to be closed for PHP 3.0.3 (bug #699) with no comment,
but it seems it isn't fixed really?


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=22226&edit=1

Reply via email to