Fixed bug #47546 (Default value for limit parameter in explode is 0, not -1)

This commit is contained in:
Kalle Sommer Nielsen 2009-03-03 11:46:20 +00:00
parent b5810c959a
commit 3980b634fd
2 changed files with 25 additions and 1 deletions

View File

@ -1311,7 +1311,7 @@ PHP_FUNCTION(explode)
} else {
add_index_stringl(return_value, 0, (char *)str, str_len, 1);
}
} else if (limit < 0 && argc == 3) {
} else if (limit < -1 && argc == 3) {
if ( str_type == IS_UNICODE ) {
php_u_explode_negative_limit((UChar *)delim, delim_len, (UChar *)str, str_len, return_value, limit);
} else {

View File

@ -0,0 +1,24 @@
--TEST--
Bug #47546 (Default value for limit parameter in explode is 0, not -1)
--FILE--
<?php
$str = 'one|two|three|four';
print_r(explode('|', $str));
print_r(explode('|', $str, -1));
?>
--EXPECT--
Array
(
[0] => one
[1] => two
[2] => three
[3] => four
)
Array
(
[0] => one
[1] => two
[2] => three
[3] => four
)