php8.5
Home/ Manual/ strings / functions/ vsprintf

vsprintf

PHP function Edit on GitHub ✎

(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)

Return a formatted string

Description

vsprintf(string $format, array $values): string

Operates as sprintf() but accepts an array of arguments, rather than a variable number of arguments.

Parameters

values

Return Values

Return array values as a formatted string according to format.

Errors/Exceptions Vsprintf

Changelog Vsprintf

Examples

vsprintf(): zero-padded integers

php
<?php
print vsprintf("%04d-%02d-%02d", explode('-', '1988-8-1'));
?>

The above example will output:

output
1988-08-01

See Also

Source: reference/strings/functions/vsprintf.xml · from the official PHP manual (php/doc-en)