|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-10-14 22:12 UTC] 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 ("")
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 19:00:01 2025 UTC |
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.