1--TEST--
2Test join() function : usage variations - different values for 'glue' 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 different glue arguments
13*/
14
15echo "*** Testing join() : usage variations ***\n";
16
17$glues = array (
18  "TRUE",
19  true,
20  false,
21  array("key1", "key2"),
22  "",
23  " ",
24  "string\x00between",
25  -1.566599999999999,
26  NULL,
27  -0,
28  '\0'
29);
30
31$pieces = array (
32  2,
33  0,
34  -639,
35  -1.3444,
36  true,
37  "PHP",
38  false,
39  NULL,
40  "",
41  " ",
42  6999.99999999,
43  "string\x00with\x00...\0"
44);
45/* loop through  each element of $glues and call join */
46$counter = 1;
47for($index = 0; $index < count($glues); $index ++) {
48  echo "-- Iteration $counter --\n";
49  var_dump( join($glues[$index], $pieces) );
50  $counter++;
51}
52
53echo "Done\n";
54?>
55--EXPECTF--
56*** Testing join() : usage variations ***
57-- Iteration 1 --
58string(91) "2TRUE0TRUE-639TRUE-1.3444TRUE1TRUEPHPTRUETRUETRUETRUE TRUE6999.99999999TRUEstring�with�...�"
59-- Iteration 2 --
60string(58) "2101-6391-1.3444111PHP1111 16999.999999991string�with�...�"
61-- Iteration 3 --
62string(47) "20-639-1.34441PHP 6999.99999999string�with�...�"
63-- Iteration 4 --
64
65Notice: Array to string conversion in %s on line %d
66string(13) "key1Arraykey2"
67-- Iteration 5 --
68string(47) "20-639-1.34441PHP 6999.99999999string�with�...�"
69-- Iteration 6 --
70string(58) "2 0 -639 -1.3444 1 PHP      6999.99999999 string�with�...�"
71-- Iteration 7 --
72string(201) "2string�between0string�between-639string�between-1.3444string�between1string�betweenPHPstring�betweenstring�betweenstring�betweenstring�between string�between6999.99999999string�betweenstring�with�...�"
73-- Iteration 8 --
74string(124) "2-1.56660-1.5666-639-1.5666-1.3444-1.56661-1.5666PHP-1.5666-1.5666-1.5666-1.5666 -1.56666999.99999999-1.5666string�with�...�"
75-- Iteration 9 --
76string(47) "20-639-1.34441PHP 6999.99999999string�with�...�"
77-- Iteration 10 --
78string(58) "2000-6390-1.3444010PHP0000 06999.999999990string�with�...�"
79-- Iteration 11 --
80string(69) "2\00\0-639\0-1.3444\01\0PHP\0\0\0\0 \06999.99999999\0string�with�...�"
81Done
82