Loader

vfprintf

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. Test vfprintf online.

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

Enter a array in the following way: [value1, value2, value3]

PHP Documentation by the PHP Documentation Group


vfprintf

(PHP 5, PHP 7)

vfprintfWrite a formatted string to a stream

Description

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

format

See sprintf() for a description of format.

args

Return Values

Returns the length of the outputted string.

Examples

Example #1 vfprintf(): zero-padded integers

<?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() - Output a formatted string
  • sprintf() - Return a formatted string
  • sscanf() - Parses input from a string according to a format
  • fscanf() - Parses input from a file according to a format
  • vsprintf() - Return a formatted string
  • number_format() - Format a number with grouped thousands

PHP Documentation

Copyright © 1997 - 2016 by the PHP Documentation Group. This material may be distributed only subject to the terms and conditions set forth in the Creative Commons Attribution 3.0 License or later. A copy of the Creative Commons Attribution 3.0 license is distributed with this manual. The latest version is presently available at » http://creativecommons.org/licenses/by/3.0/.