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

vprintf

PHP function Edit on GitHub ✎

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

Output a formatted string

Description

vprintf(string $format, array $values): int

Display array values as a formatted string according to format (which is described in the documentation for sprintf()).

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

Parameters

values

Return Values

Returns the length of the outputted string.

Errors/Exceptions Vsprintf

Changelog Vsprintf

Examples

vprintf(): zero-padded integers

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

The above example will output:

output
1988-08-01

See Also

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