1. Format
sprintf (Format, arg1, arg2, Arg3,..) writes the formatted string to the variable, and the bold font is the required parameter.
2. Description
Substitutions are performed incrementally, in order of the parameters, but if the% symbol is more than the number of arguments, the utility placeholder (consisting of numbers and \$) is applied, as an example:
sprintf("With 2 decimals: %1\$.2f<br />With no decimals: %1\$u",$number)
; Echo $txt;? >
Output:
With 2 decimals:123.00 with no decimals:123
3. Available values in the format parameter:
- Percent-return percentage symbol
- %b-Binary number
- %c-Characters in accordance with ASCII values
- %d-Signed decimal number
- %e-Sustainable counting method (e.g. 1.5e+3)
- %u-Unsigned decimal number
- %f-Floating point (Local settings Aware)
- %F-Floating point number (not local settings aware)
- %o-Eight binary number
- %s-String
- %x-16 binary number (lowercase letters)
- %x-16 decimal digits (uppercase letters)
Official explanations See: http://www.w3school.com.cn/php/func_string_sprintf.asp
PHP utility Function sprintf () detailed