PHP str_pad function using _php tutorial

Source: Internet
Author: User
String Str_pad (string, int pad_length, string pad_string, int pad_type);
String that specifies the length, pad_length, pad_string the string to fill (optional arguments), pad_type specifies the fill position (optional parameter, str_pad_left,str_pad_both);
If pad_string, Pad_type are empty, then the default pad_string is a space, and Pad_type is automatically populated at the end of the specified string.
Copy CodeThe code is as follows:
$string = "Test";
Echo Str_pad ($string, 10); Produces "test";
?>

The remaining two examples:
Copy CodeThe code is as follows:
$string = "Test";
Echo Str_pad ($string, ten, ' + ', str_pad_left); Produces "++++++test";
?>

Copy CodeThe code is as follows:
$string = "Test";
Echo Str_pad ($string, ten, ' + ', str_pad_both); Produces "+++test+++";
?>

http://www.bkjia.com/PHPjc/319831.html www.bkjia.com true http://www.bkjia.com/PHPjc/319831.html techarticle String str_pad (string, int pad_length, string pad_string, int pad_type), string specifies the length, pad_length is specified, pad_string is used to Filled string (optional parameter), Pad_type refers to ...

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