PHP Str_pad () fills a string into a string of a specified length _php tutorial

Source: Internet
Author: User
/**
* Fills a string into a string of a specified length (Multi-byte security)
* @param string $str to specify the character to be populated
* @param int $len Specifies the length of the filled string, if the value is negative or less than the length of the string is not populated
* @param string $pad _str to be populated
* @param int $pad _type Specifies the direction of the fill str_pad_right,str_pad_left or Str_pad_both
* @return String
*/

String Str_pad (string $str, int $len, String $pad _str, String $pad _type);

Echo Str_pad ($result 2[0],6, "0", str_pad_left);
Copy CodeThe code is as follows:
$input = "Alien";
Echo Str_pad ($input, 10); Produces "Alien"
Echo Str_pad ($input, ten, "-=", str_pad_left); Produces "-=-=-alien"
Echo Str_pad ($input, Ten, "_", Str_pad_both); Produces "__alien___"
Echo Str_pad ($input, 6, "___"); Produces "Alien_"
?>

http://www.bkjia.com/PHPjc/321218.html www.bkjia.com true http://www.bkjia.com/PHPjc/321218.html techarticle /** * Fills a string into a string of a specified length (multibyte security) * @param string $str Specifies the character to be populated * @param int $len Specify the length of the string to be populated, if the value ...

  • 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.