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.
When only one argument is provided to the function, this argument is considered to be a value, which will be converted to a string from its original data type. When the second argument is given, the first argument is considered a Format String and the second argument an array that contains 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.
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 | OPTIONAL 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.