PHP string left 0, the right side of the string 0

Source: Internet
Author: User

Overview: Items are often used to automatically populate the such as "0" on the left, right, or even middle of a string of encodings, and to develop a padded string length.

function Str_pad: The function returns the input result of being filled from the left, right, or both ends to the length of the set.

This may not be quite clear, let's look at a case:

STR_PDA (' Supplementary string ', ' the length of the string after the supplement ', ' what character to add ', ' Str_pad ... ');

Str_pad_left: Fill on the left

Str_pad_right: Fill on the right

Str_pad_both: Both sides complement

<?php$code = Str_pad (' PQ ', 11,0,str_pad_left); Echo $code;

Output Result:

(length=11)

PHP string left 0, the right side of the string 0

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.