#34876 [Opn->Bgs]: preg_split should return empty array when splitting ""
| From: | embeddedlinuxguy at gmail dot com | Date: | Tue, 18 Oct 2005 20:14:50 +0000 |
| Subject: | #34876 [Opn->Bgs]: preg_split should return empty array when splitting "" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-86713@lists.php.net to get a copy of this message | ||
ID: 34876
User updated by: embeddedlinuxguy at gmail dot com
Reported By: embeddedlinuxguy at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: Linux
PHP Version: 5.0.5
New Comment:
Oops, I should have used
preg_split("/q/", "", -1, PREG_SPLIT_NO_EMPTY);
which works.
If preg_split is supposed to be Perl Compatible (as in PCRE) then this
behavior ought to be changed to match Perl's split() by default:
By default, empty leading fields are preserved, and empty trailing ones
are deleted. (If all fields are empty, they are considered to be
trailing.)
Not sure if this is a PHP bug, a PCRE bug, or a feature.
Previous Comments:
------------------------------------------------------------------------
[2005-10-14 22:12:17] embeddedlinuxguy at gmail dot com
Description:
------------
$b = preg_split("/q/", "", PREG_SPLIT_NO_EMPTY);
should return an empty array (0 elements). Instead it returns an array
with one element which is an empty string, i.e. (""). This is the same
with or without PREG_SPLIT_NO_EMPTY.
Compare to Perl
my @a = split(/q/, "");
Here @a == () not ("")
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=34876&edit=1