vfprintf

(PHP 5, PHP 7)
Write a formatted string to a stream
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.

Parameters:
handle

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.

format

See sprintf() for a description of format.

args

See sprintf() for a description of format.

Returns:

Returns the length of the outputted string.

Examples:
vfprintf() : zero-padded integers
1
2
3
4
5
6
7
<?php
if (!($fp fopen('date.txt''w')))
    return;
 
vfprintf($fp"%04d-%02d-%02d"array($year$month$day));
// will write the formatted ISO date to date.txt
?>
See also:

printf() -

sprintf() -

sscanf() -

fscanf() -

vsprintf() -

number_format() -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.