Name

str_pad

Synopsis

string str_pad(string string, string length[, string pad[, int type]])

Pads string using pad until it is at least length characters and returns the resulting string. By specifying type, you can control where the padding occurs. The following values for type are accepted:

STR_PAD_RIGHT (default)

Pad to the right of string.

STR_PAD_LEFT

Pad to the left of string.

STR_PAD_BOTH

Pad on either side of string.

Get Programming PHP, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.