英[pæd] 美[pæd]

vt. To pad..., to add cushion; to stuff; to level it

vi. to walk, to walk lightly

n. Pad, lining; protective gear; pad; launching pad

Third person singular: pads Plural: pads Present participle: padding Past tense: padded Past participle: padded

php str_pad() function syntax

How to use str_pad() function?

php The str_pad() function is used to fill the string to the specified length. The syntax is str_pad(string,length,pad_string,pad_type) to fill the string to the specified length.

Function:Pall the string to the specified length

Syntax:str_pad(string,length,pad_string,pad_type)

Parameters:

Parameters Description
string Must specify the string to be filled,
length Must specify the new string length, if the value is less than the original length of the string, it will not Do any operation.
pad_string Optional, specifies the string used for padding, the default is blank.
pad_type Optional, specifies which side of the string to fill, STR_PAD_BOTH -- fills both sides of the string, if it is not an even number, the right side gets extra padding . STR_PAD_LEFT – pad the left side of the string. STR_PAD_RIGHT -- pad the right side of the string, default.

Description:Fill the string to the specified length

php str_pad() function example

"; $k = "hello world"; $h = str_pad($k,30,".",STR_PAD_LEFT);//设置填充字符串的位置为左侧 echo $h; ?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

hello world!!!!!!!!!!!!!!!!!!! ...................hello world