function sprintf () What is the solution

Source: Internet
Author: User
function sprintf () What is the role of
My PHP manual sprintf () is full of English, I can not understand. Is there any warrior who can take the function of the functions (especially the parameter format) to say it in detail?
------Solution--------------------
Yes
%.2F is formatted as 2 decimal places

Integers are naturally not decimals.

------Solution--------------------
This is a unique way to use PHP, not much (the example he gave has been very clear)
It's a normal notation.
$a = 123;
$b = 1111;
$txt = sprintf ("%.2f %u", $a, $b);
Echo $txt;
123.00 1111
When writing
$txt = sprintf ("%2\$.2f  %1\ $u", $a, $b);
Echo $txt;
1111.00 123
You can see that the value of the corresponding position has changed.
It is known that the number represents the ordinal number of the parameter
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.