I have been using echo "$".sprintf("%01\$.2f",$numvar); for my USD formatting, but I only copied and pasted that. I looked over the documentation at php.net but it’s still not clear to me.
Please help me understand what each part of "%01\$.2f" does in that function.
%is the start of the conversion specification01\$signifies that the value will be placed in the first item of the resultMore usually, the same would be written as
1$.2is the precision specifier, which dictates how many decimal digits should be displayedfmeans that the argument is treated as a float, and presented as a floating-point number (locale aware)For full details of the above, and what is available, see the description of the
formatparameter ofsprintf().