Home >Backend Development >PHP Tutorial >vsprintf() function in PHP
vsprint() function returns a formatted string.
vsprintf(format,argarray)
Format - Specifies the string and how to format the variables within it.
The following are possible format values -
%% - Returns the percent sign
%b - Binary number
%c - Convert the character to an ASCII value
%d - Signed decimal number (negative, zero, or positive)
%E - Scientific notation with uppercase letters (e.g. 1.2E 2)
%u - Unsigned decimal number (equal to or greater than zero)
%f - Float Points (local settings aware)
%F > - Floating point (local settings not supported)
%g - The shorter of %e and %f
%G - The shorter of %E and %f
%o - Octal number
##%s - String
%x - Hexadecimal number (lowercase letters)
%X - Hexadecimal number (capital letters)
arg - an array containing the arguments to insert the % symbol into the format string
<?php $a = 6567; $b = 8976; $res = vsprintf("%f</p><p>%f",array($a,$b)); echo $res; ?>Output
6567.000000 8976.000000
The above is the detailed content of vsprintf() function in PHP. For more information, please follow other related articles on the PHP Chinese website!