|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-12-28 07:26 UTC] tomas dot matousek at matfyz dot cz
Description:
------------
The explode() function misbehaves if the limit parameter has invalid value.
Reproduce code:
---------------
explode(",","a,b,c,d,e,f",-8);
explode(",","a,b,c,d,e,f",0);
Expected result:
----------------
Warning + returning FALSE
Actual result:
--------------
invalid value is treated as if it was 2 and 1 respectively
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 04:00:01 2025 UTC |
It should be so, but it is not. I've tested the following code: var_dump(explode(",","a,b,c,d,e,f",-8)); var_dump(explode(",","a,b,c,d,e,f",0)); var_dump(explode(",","a,b,c,d,e,f",1)); and got the following results (in PHP 5.0.0b2 as well as in PHP 4.3.4): array(2) { [0]=> string(1) "a" [1]=> string(9) "b,c,d,e,f" } array(1) { [0]=> string(11) "a,b,c,d,e,f" } array(1) { [0]=> string(11) "a,b,c,d,e,f" } IMHO there is a bug in the case the value is < -1. Moreover, there is no specification in manual of what the function should return if the value <= 0 (i.e. that -1 means infinity and values <-1 mean 1). Tomas Matousek