join, join ignore blanks, join unique, join unique ignore blanks
This function converts the contents of a set into a string where the opening string (e.g. an opening bracket),
a separator (e.g. a ", ") and a closing string can be provided. If the set contents are not of string type, then
they will be converted accordingly.
The ... unique ... option in the function name prevents adding repeated contents.
The ... ignore blanks ignores all values which are blank.
Attention: Nested parameters are converted according to the rules as the main set.
Indirect parameter passing is disabled
1-4
No. | Type | Description |
---|---|---|
1 input |
set | set containing values The values contained in the set will be converted |
2 input |
string | Opening or separator string If this function is called with 2 parameters only, then this value is used as separator string. |
3 input |
string | Separator string This value is used to separate the converted elements in the set Default value: '' (empty string) |
4 input |
string | Closing string This value serves as the closing string Default value: '' (empty string) |
Type | Description |
---|---|
string | Composed string Contains all set elements with the specified opening, separator and closing strings. |
echo( join( {1,'',2,' 3 ',4} ) ); // Returns: 12 3 4
echo( join( {1,'',2,' 3 ',4}, ', ' ) ); // Returns: 1, , 2, 3 , 4
echo( join( {1,'',2,' 3 ',4}, '(',', ',')' ) ); // Returns: (1, , 2, 3 , 4)
echo( join ignore blanks( {1,'',2,' 3 ',4}, '(',', ',')' ) ); // Returns: (1, 2, 3 , 4)
echo( join ignore blanks( { '' }, '(',', ',')' ) ); // Returns blank string
echo( join ( { }, '(',', ',')' ) ); // Returns blank string
echo( join( { a,b,c,a,b,c}, "," ) ); // a,b,c,a,b,c
echo( join unique( { a,b,c,a,b,c}, "," ) ); // a,b,c
echo( join( { a,b,{c,d},e }, '[', '; ', ']' ) ); // [a; b; [c; d]; e] (nested sets)
12 3 4
1, , 2, 3 , 4
(1, , 2, 3 , 4)
(1, 2, 3 , 4)
a,b,c,a,b,c
a,b,c
[a; b; [c; d]; e]