1--TEST--
2Test join() function : usage variations - sub array as argument
3--FILE--
4<?php
5/*
6 * test join() by passing pieces as array containing sub array(s)
7*/
8
9echo "*** Testing implode() : usage variations - sub arrays ***\n";
10$sub_array = array(array(1,2,3,4), array(1 => "one", 2 => "two"), "PHP", 50);
11
12// pieces as array containing sub array
13var_dump(join("TEST", $sub_array));
14
15// glue as array & pieces as array containing sub array
16try {
17    var_dump(join(array(1, 2, 3, 4), $sub_array));
18} catch (TypeError $exception) {
19    echo $exception->getMessage() . "\n";
20}
21
22// numeric value as glue, pieces as array containing sub array
23var_dump(join(2, $sub_array));
24
25// using directly the sub_array as pieces
26var_dump(join(", ", $sub_array[0]));
27var_dump(join(", ", $sub_array[1]));
28
29echo "Done\n";
30?>
31--EXPECTF--
32*** Testing implode() : usage variations - sub arrays ***
33
34Warning: Array to string conversion in %s on line %d
35
36Warning: Array to string conversion in %s on line %d
37string(27) "ArrayTESTArrayTESTPHPTEST50"
38join(): Argument #1 ($separator) must be of type string, array given
39
40Warning: Array to string conversion in %s on line %d
41
42Warning: Array to string conversion in %s on line %d
43string(18) "Array2Array2PHP250"
44string(10) "1, 2, 3, 4"
45string(8) "one, two"
46Done
47