Browse Source

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

experimental/first_unicode_implementation
Kalle Sommer Nielsen 18 years ago
parent
commit
3980b634fd
  1. 2
      ext/standard/string.c
  2. 24
      ext/standard/tests/strings/bug47546.phpt

2
ext/standard/string.c

@ -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

@ -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…
Cancel
Save