Tag Link | [Array->Insert] | Category | Array |
---|---|---|---|
Type | Member | Source Available | No |
Support | Preferred | Version | 5.0 |
Change | Unchanged | Data Source | Any |
Output Type | None | Security | None |
Implementation | LCAPI | Sets | Lasso 8.5, Lasso 8.0, Lasso 7.0, Lasso 6.0, Lasso 5.0 |
[Array->Insert] inserts a value into the array. Accepts a single parameter which is the value to be inserted and an optional integer parameter identifying the position of the location where the value should be inserted. Defaults to inserting the parameter at the end of the array. Returns no value.
The first element in an array is at position 1.
Note: This tag will not replace an item in the array. Instead, it will insert the new item and increment the position of all the existing items that follow.
[Array->(Insert: 'Insert Value')]
[Array->(Insert: 'Insert Value', Array Position)]
Required Parameters | |
---|---|
Insert Value | The value which should be inserted as the last element of the array. |
Optional Parameters | |
Array Index | The index of the element where the new item should be inserted. Defaults to inserting at the end of the array. |
To insert a new element into an array:
Use the [Array->Insert] tag. The following example starts with a partial array of the days of the week, then inserts 'Sun' as the first element and 'Sat' as the last element of the array.
<?LassoScript
Variable: 'DaysOfWeek'=(Array:'Mon','Tue','Wed','Thu','Fri');
$DaysOfWeek->(Insert: 'Sun', 1);
$DaysOfWeek->(Insert: 'Sat');
Output: $DaysOfWeek;
?>
(Array: (Sun), (Mon), (Tue), (Wed), (Thu), (Fri), (Sat))