1--TEST--
2Test join() function : usage variations - sub array as argument
3--FILE--
4<?php
5/* Prototype  : string join( string $glue, array $pieces )
6 * Description: Join array elements with a string
7 * Source code: ext/standard/string.c
8 * Alias of function: implode()
9*/
10
11/*
12 * test join() by passing pieces as array containing sub array(s)
13*/
14
15echo "*** Testing implode() : usage variations - sub arrays ***\n";
16$sub_array = array(array(1,2,3,4), array(1 => "one", 2 => "two"), "PHP", 50);
17
18// pieces as array containing sub array
19var_dump( join("TEST", $sub_array) );
20
21// glue as array & pieces as array containing sub array
22var_dump( join(array(1, 2, 3, 4), $sub_array) );
23
24// numeric value as glue, pieces as array containg sub array
25var_dump( join(2, $sub_array) );
26
27// using directly the sub_array as pieces
28var_dump( join(", ", $sub_array[0]) );
29var_dump( join(", ", $sub_array[1]) );
30
31echo "Done\n";
32?>
33--EXPECTF--
34*** Testing implode() : usage variations - sub arrays ***
35
36Notice: Array to string conversion in %s on line %d
37
38Notice: Array to string conversion in %s on line %d
39string(27) "ArrayTESTArrayTESTPHPTEST50"
40
41Notice: Array to string conversion in %s on line %d
42string(19) "1Array2Array3Array4"
43
44Notice: Array to string conversion in %s on line %d
45
46Notice: Array to string conversion in %s on line %d
47string(18) "Array2Array2PHP250"
48string(10) "1, 2, 3, 4"
49string(8) "one, two"
50Done
51