PHP number plus zero fixed digits plus 0

Source: Internet
Author: User
: This article describes how to add a fixed number of PHP numbers to 0. For more information about PHP tutorials, see. When processing order numbers, a fixed number is required. for example, a fixed four-digit format is required:

1-> 000156-> 0056288-> 02881992-> 1992

You can use the php built-in function str_pad () to fill the string with a new length.

Str_pad (string, length, pad_string, pad_type) // The parameter description string // required. Specifies the string to be filled. Length // required. Specify the length of the new string. If the value is smaller than the original length of the string, no operation is performed. Pad_string // optional. The specified string for filling. The default value is blank. Pad_type // optional. Specifies the side of the string to be filled. // Possible value: STR_PAD_BOTH-// fill both sides of the string. If it is not an even number, the right side will receive additional filling. STR_PAD_LEFT-// fill the left side of the string. STR_PAD_RIGHT-// fill the right side of the string. Default value.

Example:

$ Num= 128; $ num = str_pad ($ num, 4, "0", STR_PAD_LEFT); echo $ num;

Output

0128

'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
  • '). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script

    The above section introduces the PHP number plus 0 by zero fixed digits, including some content. I hope my friends who are interested in the PHP Tutorial will be helpful.

    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.