This function creates a new string, allowing you to insert placeholders in the main "format string", and to specify an array containing the values to be inserted into those placeholders.
The first argument is a Format String and the second argument is an array containing values to be inserted into the format string.
For information on format strings, see: string()
This function works in a similar manner, but instead of the values being passed as separate arguments, they're passed as an array in the second argument.
NOTE You can also use Template Strings to insert variables and expressions into strings.
string_ext(value_or_format, values);
Argument | Type | Description |
---|---|---|
value_or_format | Any (if value) or String (if format) | The value to be turned into a string. |
values | Array | An array of values to be inserted at the placeholder positions. |
numbers = [59, 23, 656, 8, 54];
array_sort(numbers, true);
var _str = string_ext("The three lowest numbers are: {0}, {1} and {2}", numbers);
The above code first defines an array with some numbers, and sorts them in an ascending order. It then uses that array in a string_ext() to call to insert its first three numbers into a format string.