c语言formatted string
的有关信息介绍如下:下面是我整理后的,希望能帮到你!
sprintf
(PHP 4, PHP 5, PHP 7, PHP 8)
sprintf — Return a formatted string
说明
sprintf ( string $format , mixed ...$values ) : string
Returns a string produced according to the formatting string format.
参数
format
The format string is composed of zero or more directives: ordinary characters (excluding %) that are copied directly to the result and conversion specifications, each of which results in fetching its own parameter.
A conversion specification follows this prototype: %[argnum$][flags][width][.precision]specifier.
Argnum
An integer followed by a dollar sign $, to specify which number argument to treat in the conversion.
Flags
Flag 说明
- Left-justify within the given field width; Right justification is the default
+ Prefix positive numbers with a plus sign +; Default only negative are prefixed with a negative sign.
(space) Pads the result with spaces. This is the default.
0 Only left-pads numbers with zeros. With s specifiers this can also right-pad with zeros.
'(char) Pads the result with the character (char).