Str::template()
Replaces placeholders in string with values from the data array
Str::template(string|null $string, array $data = [], array{fallback?: string|null, callback?: Closure|null, start?: string, end?: string} $options = []): string
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| $string | stringornull |
no default value | |
| $data | array<string, mixed> |
[]
|
Placeholders as keys and replacements as values; supports query syntax |
| $options | array{fallback?: string|null, callback?: Closure|null, start?: string, end?: string} |
[]
|
Return type
string
Parent class
Examples
echo Str::template('From {{ b }} to {{ a }}', ['a' => 'there', 'b' => 'here']);
// output: From here to there