fastFormat.php
Table of Contents
Functions
- fastFormat() : string
- Quickly formats a string using indexed placeholders and arguments.
Functions
fastFormat()
Quickly formats a string using indexed placeholders and arguments.
fastFormat(string|null $pattern, mixed ...$args) : string
This function replaces indexed tokens like {0}
, {1}
, etc. in a pattern string
with corresponding values from a list of arguments or an array.
- If arguments are passed as a list:
fastFormat("{0} {1}", "hello", "world")
- If passed as a single array:
fastFormat("{0} {1}", ["hello", "world"])
Parameters
- $pattern : string|null
-
The format string containing indexed placeholders.
- $args : mixed
-
The values to insert, either as variadic args or a single array.
Tags
Return values
string —The formatted string with placeholders replaced by values.