PHP String vsprintf() Function
The vsprintf() function is an in-built function of PHP, which is used to display the array values as a formatted string. It works similar to the sprintf() function, but it accepts an array of arguments rather a variable number of arguments. PHP 4.1.0 and above versions support this function.
In this function, the elements of the array along with the percent (%) signs in the main string. It displays the array values as the formatted string according to its format. It returns the formatted string.
There are some other functions, which are similar to the vsprintf().
The syntax of the vsprintf() function is given below, which accepts two parameters, and both are mandatory.
$format (required) - It is a mandatory parameter of vsprintf() function, which specifies how to format a variable in it.
Possible format specifiers values:
Warning: The c specifier ignores the width and padding.
Additional format values:
$array_args (required)- This is also a mandatory parameter of this function. It specifies an array containing the arguments to be inserted at the % signs in the format string.
The vsprintf() function returns the formatted string.
Below is the list of examples, by which we can learn the implementation of the vsprintf() function.
My enrollment number is: 3215