Tag Link | [Array->Join] | Category | Array |
---|---|---|---|
Type | Member | Source Available | No |
Support | Preferred | Version | 6.0 |
Change | Unchanged | Data Source | Any |
Output Type | String | Security | Tag |
Implementation | LCAPI | Sets | Lasso 8.5, Lasso 8.0, Lasso 7.0, Lasso 6.0 |
The [Array->Join] tag concatenates (or adds) each of the elements of an array together. An optional parameter specifies a value that should be concatenated between each element of the array.
The [Array->Join] tag uses the + symbol to combine the element of the array and the optional parameter. If all the elements of the array are integers then a sum will be performed [(Array: 1, 2, 3)->Join] -> 6.
Usually, the parameter to the [Array->Join] tag is a string. This forces a string concatenation to occur so that the result is a string [(Array, 1, 2, 3)->(Join: ' ')] -> '1 2 3'. A non
If the array only contains a single element then that element will be returned and no concatenation or addition is performed. If desired the [String] tag can be used to force the result to be a string.
[Array->(Join: 'String')]
[Array->(Join: ' ')]
[Array->(Join: ', ')]
[Output: '\'' + Array->(Join: '\',\'') + '\'']
[(Array: 1, 2, 3)->(Join: 0)]
Optional Parameters | |
---|---|
String Delimiter | A string which will be inserted between each element of the joined array. |
To join an array into a string:
Use the [Array->Join] tag.
In the following example a URL is divided into segments on the ampersand character using the [Array->Split] tag. A new name/value pair is added to the array then the array is rejoined using [Array->Join].
[Variable: 'myURL' = 'http://www.example.com/Default.Lasso?
[Variable: 'myArray' = $myURL->(Split: '&')]
[$myArray->(Insert: 'First_Name=J')]
[Variable: 'myURL' = $myArray->(Join: '&')]
[Output: $myURL]
http://www.example.com/Default.Lasso?