|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-02-14 16:47 UTC] php at savignano dot de
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? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sun Jan 11 23:00:01 2026 UTC |
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.