mirror of
https://github.com/php/php-src.git
synced 2024-10-19 07:22:40 +00:00
82 lines
2.2 KiB
PHP
82 lines
2.2 KiB
PHP
--TEST--
|
||
Test join() function : usage variations - different values for 'glue' argument
|
||
--FILE--
|
||
<?php
|
||
/* Prototype : string join( string $glue, array $pieces )
|
||
* Description: Join array elements with a string
|
||
* Source code: ext/standard/string.c
|
||
* Alias of function: implode()
|
||
*/
|
||
|
||
/*
|
||
* test join() by passing different glue arguments
|
||
*/
|
||
|
||
echo "*** Testing join() : usage variations ***\n";
|
||
|
||
$glues = array (
|
||
"TRUE",
|
||
true,
|
||
false,
|
||
array("key1", "key2"),
|
||
"",
|
||
" ",
|
||
"string\x00between",
|
||
-1.566599999999999,
|
||
NULL,
|
||
-0,
|
||
'\0'
|
||
);
|
||
|
||
$pieces = array (
|
||
2,
|
||
0,
|
||
-639,
|
||
-1.3444,
|
||
true,
|
||
"PHP",
|
||
false,
|
||
NULL,
|
||
"",
|
||
" ",
|
||
6999.99999999,
|
||
"string\x00with\x00...\0"
|
||
);
|
||
/* loop through each element of $glues and call join */
|
||
$counter = 1;
|
||
for($index = 0; $index < count($glues); $index ++) {
|
||
echo "-- Iteration $counter --\n";
|
||
var_dump( join($glues[$index], $pieces) );
|
||
$counter++;
|
||
}
|
||
|
||
echo "Done\n";
|
||
?>
|
||
--EXPECTF--
|
||
*** Testing join() : usage variations ***
|
||
-- Iteration 1 --
|
||
string(91) "2TRUE0TRUE-639TRUE-1.3444TRUE1TRUEPHPTRUETRUETRUETRUE TRUE6999.99999999TRUEstring |