← All built-ins / str_pad()
str_pad()
str_pad(...$args): string
Parameters
| Name | Type | Description |
|---|---|---|
| $s | string | input string |
| $len | int | target length in bytes |
| $pad | string | pad string, default " " (space)optional |
Return value
The string padded on the right with repeats of $pad up to $len bytes; unchanged when already longer.
Example
echo "[" . str_pad("7", 3, "0") . "]", "
";
echo "[" . str_pad("id:", 6) . "]", "
";[700] [id: ]