![]() |
VOOZH | about |
The vsprintf() function in PHP is an inbuilt function and used to display array values as a formatted string. The array elements will be inserted at the percent (%) signs in the main string. Display array values as a formatted string according to its format and accepts an array argument in place of variable number of arguments. The function returns formatted string. while vprintf() outputs a formatted string
Syntax:
vsprintf (format, arr_arguments)
Parameters Used : This Function takes Two parameter which are described below-
Additional format:
Program 1: String space specified program.
Geeks Geeks Geeks 000000000000000Geeks *****Geeks Geeksforgeeksarticle Geeksforge Geeksforgeeksarticle 0000000000Geeksforgeeksarticle
Program 2: Drive floating program %f and %F in vsprintf() function in PHP.
%f (local) Floating: 789495321.000000 8080907021.000000 334422190.000000 %F (Not local) Floating: 789495321.000000 8080907021.000000 334422190.000000
Program 3: Implement %d, %u, %e and %E in vsprintf() function.
%d Signed decimal number : 7894 9070 3344 %u UnSigned decimal number : 7894 9070 3344 %e Scientific notation : 7.894000e+3 9.070000e+3 3.344000e+3 %E Scientific notation : 7.894000E+3 9.070000E+3 3.344000E+3
Program 4: Implement %%, %b, %o, %x, and %Xin vsprintf() function in PHP.
% ->Returns [%] sign: % % %b ->binary number : 11000000101111110111 1010001101001110111 %o ->octal number : 3005767 1215167 %x ->Hexadecimal number Lc : c0bf7 51a77 %X ->Hexadecimal number Uc : C0BF7 51A77
Program 5:Implement %g %G and %c(ASCII) vsprintf() function in PHP.
%g shorter of %e and %f: 75 55 %G shorter of %E and %f : 75 55 %c ASCII value : a E
Related Article: PHP | vprintf() function
References: https://www.php.net/manual/en/function.vsprintf.php