String function Library: Str_pad

Source: Internet
Author: User
Keywords PHP Chinese function Manual Str_pad
Tags aliyun function function library html http it is php php chinese function manual

Str_pad

(PHP4 >= 4.0.1)

Str_pad---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; The padding string becomes the specified length

Syntax: string str_pad (string input, int pad_length [, string pad_string [, int pad_type]])

Description:

This function is padded to the left, right, or left and right of the string parameter input to become the specified padding length. If the pad_string option is not provided, the parameter input is padded with white space, otherwise it is padded to the specified length using pad_string.

Non-required options pad_type can be str_pad_right, str_pad_left, or Str_pad_both, and if Pad_type is not specified, it is assumed to be str_pad_right.

If the value of the pad_length is a negative number or is less than the length of the input string, it is not padded.

Example:

<?php

$input = "Alien";

Print Str_pad ($input, 10); Produces "Alien"

Print Str_pad ($input, ten, "=", str_pad_left); Produces "-=-=-alien"

Print Str_pad ($input, "_", Str_pad_both); Produces "__alien___"

?>

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.