php str_pad () function syntax
str_pad () function how to use?
php str_pad () function is used to fill the string to a specified length, the syntax is str_pad (string, length, pad_string, pad_type), filling the string length specified. Marble feet
Effect: the string is filled into the specified length
语法:str_pad(string,length,pad_string,pad_type)
parameter:
parameter | description |
string | Must require the string to be filled, |
length | It must new predetermined length of the string, if the value is less than the original length of the string, no operation. |
pad_string | Optionally, the provisions of the string used to fill, the default is blank. |
pad_type | Alternatively, filling a predetermined string which side, STR_PAD_BOTH - on both sides of the filling of the string, if not an even number, the right side of the additional padding. STR_PAD_LEFT - side of the filler strings. STR_PAD_RIGHT - filling the right of the string, by default. |
Description: The character string specified length filled
php str_pad () function examples
? <PHP $ I = "Hello World"; $ J = str_pad (I $, 30, "!"); // string filling position is not set, the default is right echo $ J; echo "<br>"; = K $ "Hello World"; $ H = str_pad ($ K, 30,, STR_PAD_LEFT "."); // set the position of the string is left filled echo $ H; ?>