Pads a string.
str_pad() extends a string by adding characters to one or both of its ends. The length parameter specifies the total length of the returned string. The optional pad_string is a sequence of characters to use for padding. If it is not specified, spaces will be used. The optional side parameter specifies which side to pad on. Default is on the right and possible values are STR_PAD_RIGHT, STR_PAD_LEFT, and STR_PAD_BOTH. A new padded string is returned.
<?php
$s = "Hello";
print str_pad($s, 9, "*") . "<br>";
print str_pad($s, 13, "/-", STR_PAD_BOTH);
?>
Hello****
/-/-Hello/-/-
str_pad() is used to pad the same string, first on the default right side and then on both sides.