Home >>PHP String Functions >PHP vprintf() Function
PHP vprintf() function is used to display array values as a formatted string according to format. It work similar as printf() but accepts an array as the arguments in place of variables. It returns the length of the output string on success.
Syntax:
vprintf($format, $array);
Parameter | Description |
---|---|
format | This is a required parameter. This parameter defines the string and how to format the variables in it. |
array | This is a required parameter. This parameter defines an array with arguments to be inserted at the % signs in the format string. |
Here is an example of vprintf() function in PHP:
<html> <body> <?php $name = "Jerry"; $age = "21"; vprintf("My name is %s and i'm %u years old.",array($name,$age)); ?> </body> </html>
Here is an example of vprintf() function in PHP:
<html> <body> <?php $number = 955; vprintf("Price of this product is %1\$.2f",array($number)); ?> </body> </html>