PHP vfprintf() Function

The vfprintf() function writes a formatted string to a specified output stream (example: file or database).

Unlike fprintf(), the arguments in vfprintf(), are placed in an array. The array elements will be inserted at the percent (%) signs in the main string. This function works "step-by-step". At the first % sign, the first array element is inserted, at the second % sign, the second array element is inserted, etc.

int vfprintf ( resource $handle , string $format , array $args )

Write a string produced according to format to the stream resource specified by handle.

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

Example -

Example #1 vfprintf(): zero-padded integers

ParameterDescription
streamRequired. Specifies where to write/output the string
formatSee sprintf() for a description of format.
argarrayRequired. An array with arguments to be inserted at the % signs in the format string

Returns the length of the outputted string.