1--TEST--
2Test explode() function : usage variations - misc tests
3--FILE--
4<?php
5
6echo "*** Testing explode() function: misc tests ***\n";
7
8$str = "one\x00two\x00three\x00four";
9
10echo "\n-- positive limit with null separator --\n";
11$e = test_explode("\x00", $str, 2);
12
13echo "\n-- negative limit (since PHP 5.1) with null separator --\n";
14$e = test_explode("\x00", $str, -2);
15
16echo "\n-- unknown string --\n";
17$e = test_explode("fred", $str,1);
18
19echo "\n-- limit = 0 --\n";
20$e = test_explode("\x00", $str, 0);
21
22echo "\n-- limit = -1 --\n";
23$e = test_explode("\x00", $str, -1);
24
25echo "\n-- large limit = -100 --\n";
26$e = test_explode("\x00", $str, 100);
27
28function test_explode($delim, $string, $limit)
29{
30    $e = explode($delim, $string, $limit);
31    foreach ( $e as $v)
32    {
33        var_dump(bin2hex($v));
34    }
35}
36?>
37--EXPECT--
38*** Testing explode() function: misc tests ***
39
40-- positive limit with null separator --
41string(6) "6f6e65"
42string(28) "74776f00746872656500666f7572"
43
44-- negative limit (since PHP 5.1) with null separator --
45string(6) "6f6e65"
46string(6) "74776f"
47
48-- unknown string --
49string(36) "6f6e650074776f00746872656500666f7572"
50
51-- limit = 0 --
52string(36) "6f6e650074776f00746872656500666f7572"
53
54-- limit = -1 --
55string(6) "6f6e65"
56string(6) "74776f"
57string(10) "7468726565"
58
59-- large limit = -100 --
60string(6) "6f6e65"
61string(6) "74776f"
62string(10) "7468726565"
63string(8) "666f7572"
64