mb_str_pad
Function • Added in PHP 8.3
Pad a multibyte string to a certain length with another multibyte string.
mb_str_pad Function synopsis
mb_str_pad(
string $string,
int $length,
string $pad_string = " ",
int $pad_type = STR_PAD_RIGHT,
?string $encoding = null
): string
Parameters
$string
Typestring
The input string.
$length
Typeint
If the value of $length is negative,
less than, or equal to the length of the input string, no padding
takes place, and $string will be returned.
$pad_string
OptionalTypestringDefault value" "
The $pad_string may be truncated if the
required number of padding characters can't be evenly divided by the
$pad_string's length.
$pad_type
OptionalTypeintDefault valueSTR_PAD_RIGHT
Optional argument $pad_type can be
STR_PAD_RIGHT, STR_PAD_LEFT,
or STR_PAD_BOTH.
By default STR_PAD_RIGHT.
$encoding
OptionalType?stringDefault valuenull
Return value
Typestring
Returns the padded string.
Changes to the mb_str_pad Function
PHP 8.3
- Function added
mb_str_pad Function Availability
mb_str_pad Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | No |
| PHP 8.1Unsupported | No |
| PHP 8.0Unsupported | No |
| PHP 7.4Unsupported | No |
| PHP 7.3Unsupported | No |
| PHP 7.2Unsupported | No |
| PHP 7.1Unsupported | No |
| PHP 7.0Unsupported | No |
| PHP 5.6Unsupported | No |
| PHP 5.5Unsupported | No |
| PHP 5.4Unsupported | No |
| PHP 5.3Unsupported | No |