Annotation of embedaddon/php/ext/standard/tests/strings/join_basic.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
11: echo "*** 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
18: var_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");
23: var_dump( join($glue, $pieces) );
24:
25: // pices as associative array (numeric values)
26: $pieces = array("Hour" => 10, "Minute" => 20, "Second" => 40);
27: $glue = ':';
28: var_dump( join($glue, $pieces) );
29:
30: // pices as associative array (string/numeric values)
31: $pieces = array("Day" => 'Friday', "Month" => "September", "Year" => 2007);
32: $glue = '/';
33: var_dump( join($glue, $pieces) );
34:
35: echo "Done\n";
36: ?>
37: --EXPECTF--
38: *** Testing join() : basic functionality ***
39: string(7) "1,2,3,4"
40: string(30) "Red, Green, Blue, Black, White"
41: string(8) "10:20:40"
42: string(21) "Friday/September/2007"
43: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>