Hasan Setiawan

Write, write, write give your wings on code!

Follow me on GitHub

PHP vfprintf() Function

The PHP vfprintf() function is used to write a formatted string to a specified output stream like a file.
It has the following syntax

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

Here is an example of using vfprintf():

      
    $number = 9;
    $fruit = "Apples";
    $file = fopen("food.txt","w");
    echo vfprintf($file,"The group ate %u %s today.",array($number,$fruit));
    //  Outputs: 29 and writes "The group ate 9 Apples today." to the file.