PHP vfprintf Function
What is vfprintf Function?
Explanation
This function is used to write a formatted string to a stream.
Syntax:
vfprintf(stream,format,argarray)
In the above syntax "stream" specifies where to write the string,"format" specifes the formatting string to be used "%%", "%b", "%c", "%d", "%e", "%u", "%f", "%F", "%o", "%s", "%x", "%X", "argarray" specifies an array with arguments to be inserted at % sign.
Example :
<?php
$str = "Hi";
$number = 200;
$file = fopen("test.txt","w");
echo vfprintf($file,"%s my mark is %u",array($str,$number));
?>
Result in the browser:
17
Result in "test.txt".
Hi my mark is 200
In the above PHP example the output is written into the file "test.txt", the string is written based on the formatting strings.