Array functions allow you to concatenate, insert, remove, sort, and count elements in arrays.
arr_concat
Concatenates strings in an array by using a specified delimiter.
| Item | Description |
| Syntax | arr_concat(tbl, sep) |
| Parameter |
|
| Example | |
| Return value | Returns the concatenated string. In this example, t1&t2&t3 is returned. |
arr_insert
Inserts an element into an array.
| Item | Description |
| Syntax | arr_insert(list, value, [pos]) |
| Parameter |
|
| Example | |
| Return value | Returns true. In this example, arr_insert:61352 is returned. |
arr_remove
Removes an element at the specified position from an array and returns the removed element. If you do not specify the pos parameter, the last element is removed.
| Item | Description |
| Syntax | arr_remove(list, [pos]) |
| Parameter |
|
| Example | |
| Return value | Returns the removed element. In this example, arr_remove:3 is returned. |
arr_sort
Sorts elements in an array in a specified order.
- If you specify the comp parameter, it must be a function that accepts two array elements as parameters. The function returns true if the first element should be placed before the second element.
- If you do not specify the comp parameter, elements are sorted by ASCII codes in ascending order. This sorting algorithm is unstable and may change the original order of elements with equal values.
| Item | Description |
| Syntax | arr_sort(list, [comp]) |
| Parameter |
|
| Example | |
| Return value | Returns true. In this example, the following values are returned: |
arr_len
Returns the number of elements in an array.
| Item | Description |
| Syntax | arr_len(arr) |
| Parameter | arr: the array. |
| Example | |
| Return value | Returns the number of elements in the array. Data type: numeric. In this example, 1 is returned. |