1--TEST--
2Test join() function : basic functionality
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
11echo "*** Testing join() : basic functionality ***\n";
12
13// Initialize all required variables
14$glue = ',';
15$pieces = array(1, 2, 3, 4);
16
17// pieces as arry with numeric values
18var_dump( join($glue, $pieces) );
19
20// pieces as array with strings values
21$glue = ", "; // multiple car as glue
22$pieces = array("Red", "Green", "Blue", "Black", "White");
23var_dump( join($glue, $pieces) );
24
25// pices as associative array (numeric values)
26$pieces = array("Hour" => 10, "Minute" => 20, "Second" => 40);
27$glue = ':';
28var_dump( join($glue, $pieces) );
29
30// pices as associative array (string/numeric values)
31$pieces = array("Day" => 'Friday', "Month" => "September", "Year" => 2007);
32$glue = '/';
33var_dump( join($glue, $pieces) );
34
35echo "Done\n";
36?>
37--EXPECTF--
38*** Testing join() : basic functionality ***
39string(7) "1,2,3,4"
40string(30) "Red, Green, Blue, Black, White"
41string(8) "10:20:40"
42string(21) "Friday/September/2007"
43Done
44