Index: ext/standard/string.c =================================================================== RCS file: /repository/php-src/ext/standard/string.c,v retrieving revision 1.445.2.14.2.81 retrieving revision 1.445.2.14.2.82 diff -u -3 -p -r1.445.2.14.2.81 -r1.445.2.14.2.82 --- ext/standard/string.c 14 Feb 2009 07:00:24 -0000 1.445.2.14.2.81 +++ ext/standard/string.c 3 Mar 2009 11:50:32 -0000 1.445.2.14.2.82 @@ -1042,7 +1042,7 @@ PHP_FUNCTION(explode) if (limit == 0 || limit == 1) { add_index_stringl(return_value, 0, Z_STRVAL_PP(str), Z_STRLEN_PP(str), 1); - } else if (limit < 0 && argc == 3) { + } else if (limit < -1 && argc == 3) { php_explode_negative_limit(*delim, *str, return_value, limit); } else { php_explode(*delim, *str, return_value, limit); --- /dev/null 2009-03-17 12:44:35.543007618 +0100 +++ ext/standard/tests/strings/bug47546.phpt 2009-03-03 12:50:32.000000000 +0100 @@ -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 +)