join ...

Prev Next

Function Names

join, join ignore blanks, join unique, join unique ignore blanks

Description

This function converts the contents of a parameter 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 parameter 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 parameter set.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1-4

Parameters

No.TypeDescription
1
input
parameter set Parameter set containing values

The values contained in the parameter 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.
If this function is called with 3 or more parameters, then this value is used as opening string.

Default value: '' (empty string)
3
input
string Separator string

This value is used to separate the converted elements in the parameter set

Default value: '' (empty string)
4
input
string Closing string

This value serves as the closing string

Default value: '' (empty string)

Return value

TypeDescription
string Composed string

Contains all parameter set elements with the specified opening, separator and closing strings.

Examples


      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)

Output

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]
Try it yourself: Open LIB_Function_join.b4p in B4P_Examples.zip. Decompress before use.

See also

string conversion functions