mirror of
https://github.com/php/php-src.git
synced 2024-09-27 04:47:22 +00:00
Fixed bug #47546 (Default value for limit parameter in explode is 0, not -1)
This commit is contained in:
parent
b5810c959a
commit
3980b634fd
@ -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 {
|
||||
|
24
ext/standard/tests/strings/bug47546.phpt
Normal file
24
ext/standard/tests/strings/bug47546.phpt
Normal 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
|
||||
)
|
Loading…
Reference in New Issue
Block a user