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