String.fill
fill($value0, $value1, ...) -> string
Description
Fill placeholders {}
with the given values, in the order they are passed in.
'Hello, {}'.fill('Deer') //= 'Hello, Deer' '{} eats {}'.fill('Monkey', 'Banana') //= 'Monkey eats Banana'
Values can also be passed as a single List.
$values = ['Bear', 'Honey'] '{} eats {}'.fill(values) //= 'Bear eats Honey'
Use numeric placeholders to pass them in a different order.
'{2} eats {1}'.fill('Monkey', 'Banana') //= 'Banana eats Monkey'
If values are passed as a Map, it will fill in placeholders by key name.
$animal = { name: 'Snail', food: 'Leaves' } '{name} eats {food}'.fill($animal) //= 'Snail eats Leaves'