string str_pad (string, int pad_length, string pad_string, int pad_type);
string specifies the string, pad_length specifies the length, pad_string is used to fill the string (optional parameter), pad_type specifies the padding position (optional parameter, STR_PAD_LEFT ,STR_PAD_BOTH);
If pad_string and pad_type are both empty, it means that the default pad_string is a space, and pad_type is automatically filled 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 the code The code is as follows:
$string = "test";
echo str_pad($string , 10,'+',STR_PAD_LEFT); // produces "++++++test";
?>
Copy code The code is as follows:
$string = "test" ;
echo str_pad($string , 10,'+',STR_PAD_BOTH); // produces "+++test+++";
?>
http://www.bkjia.com/PHPjc/319831.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319831.htmlTechArticlestring str_pad ( string , int pad_length , string pad_string , int pad_type); string specifies the string, pad_length specifies the length, pad_string is the string used to fill (optional parameter), pad_type refers to...