sprintf

PHP 4, PHP 5, PHP 7, PHP 8
sprintf - Return a formatted string
Sprintf Online Tool
Manual
Code Examples

Example #1 Argument swapping

Result: There are 5 monkeys in the tree
PHP Version:

Example #2 Specifying padding character

Result: ......123 000000123
PHP Version:

Example #3 Position specifier with other specifiers

Result: The tree contains 0005 monkeys
PHP Version:

Example #4 sprintf: formatting currency

Result: 123.1 123.10
PHP Version:

Example #5 sprintf: scientific notation

Result: 3.625e+8
PHP Version:

Example #6 sprintf: zero-padded integers

PHP Version:


Example #7 of sprintf

PHP Version:


Function sprintf:

Strings Functions

Most used PHP functions