1--TEST--
2Test explode() function : usage variations - positive and negative limits
3--FILE--
4<?php
5
6/* Prototype  : array explode  ( string $delimiter  , string $string  [, int $limit  ] )
7 * Description: Split a string by string.
8 * Source code: ext/standard/string.c
9*/
10
11echo "*** Testing explode() function: positive and negative limits ***\n";
12$str = 'one||two||three||four';
13
14echo "\n-- positive limit --\n";
15var_dump(explode('||', $str, 2));
16
17echo "\n-- negative limit (since PHP 5.1) --\n";
18var_dump(explode('||', $str, -1));
19
20echo "\n-- negative limit (since PHP 5.1) with null string -- \n";
21var_dump(explode('||', "", -1));
22?>
23===DONE===
24--EXPECT--
25*** Testing explode() function: positive and negative limits ***
26
27-- positive limit --
28array(2) {
29  [0]=>
30  string(3) "one"
31  [1]=>
32  string(16) "two||three||four"
33}
34
35-- negative limit (since PHP 5.1) --
36array(3) {
37  [0]=>
38  string(3) "one"
39  [1]=>
40  string(3) "two"
41  [2]=>
42  string(5) "three"
43}
44
45-- negative limit (since PHP 5.1) with null string --
46array(0) {
47}
48===DONE===