ArticleDirectory
- Syntax
- Example 1
- Example 2
- Example 3
- Syntax
- Example 1
- Example 2
- Example 3
Introduction: This is a detailed page on how PHP intercepts strings and completes str_pad () Functions with zero padding. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 334794 'rolling = 'no'>
Definition and usage
The str_pad () function fills the string with the specified length.
Syntax
Str_pad (string, length, pad_string, pad_type)
Parameters |
Description |
String |
Required. Specifies the string to be filled. |
Length |
Required. Specify the length of the new string. If the value is smaller than the length of the original string, no operation is performed. |
Pad_string |
Optional. The specified string for filling. The default value is blank. |
Pad_type |
Optional. Specify the other side of the string to be filled. Possible values:
- Str_pad_both-fill in the two ends of the string. If it is not an even number, the right side will receive additional filling.
- Str_pad_left-fill in the left side of the string.
- Str_pad_right-fill in the string to the right. This is the default one.
|
Example 1
<? PHP
$ STR = "http://www.my400800.cn
";
Echo str_pad ($ STR, 30 ,".");
?>
Output:
Http://www.my400800.cn ........
Example 2
<? PHP
$ STR = "http://www.my400800.cn
";
Echo str_pad ($ STR, 30, ".", str_pad_left );
?>
Output:
...... Http://www.my400800.cn
Example 3
<? PHP
$ STR = "http://www.my400800.cn ";
Echo str_pad ($ STR, 30, ".:", str_pad_both );
?>
Output:
..: Http://www.my400800.cn .:.:
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/334794.html pageno: 10.
Definition and usage
The str_pad () function fills the string with the specified length.
Syntax
Str_pad (string, length, pad_string, pad_type)
Parameters |
Description |
String |
Required. Specifies the string to be filled. |
Length |
Required. Specify the length of the new string. If the value is smaller than the length of the original string, no operation is performed. |
Pad_string |
Optional. The specified string for filling. The default value is blank. |
Pad_type |
Optional. Specify the other side of the string to be filled. Possible values:
- Str_pad_both-fill in the two ends of the string. If it is not an even number, the right side will receive additional filling.
- Str_pad_left-fill in the left side of the string.
- Str_pad_right-fill in the string to the right. This is the default one.
|
Example 1
<? PHP
$ STR = "http://www.my400800.cn
";
Echo str_pad ($ STR, 30 ,".");
?>
Output:
Http://www.my400800.cn ........
Example 2
<? PHP
$ STR = "http://www.my400800.cn
";
Echo str_pad ($ STR, 30, ".", str_pad_left );
?>
Output:
...... Http://www.my400800.cn
Example 3
<? PHP
$ STR = "http://www.my400800.cn ";
Echo str_pad ($ STR, 30, ".:", str_pad_both );
?>
Output:
..: Http://www.my400800.cn .:.: