← All built-ins / sprintf()
sprintf()
sprintf(...$args): string
Parameters
| Name | Type | Description |
|---|---|---|
| $format | string | format string with % placeholders |
| $... | mixed | values for the placeholders |
Return value
The formatted string. Specifiers: %d %s %f %x %o %b %e %c, with width, precision and "-" left-align.
Example
echo sprintf("%s has %d points", "Ada", 42), "
";
echo sprintf("%.2f", 3.14159), "
";
echo sprintf("%05d", 42), "
";Ada has 42 points 3.14 00042