STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH:
<?
$string = "Goodbye, Perl!";
$a = str_pad($string, 10, '-', STR_PAD_LEFT);
$b = str_pad($string, 10, '-', STR_PAD_RIGHT);
$c = str_pad($string, 10, '-', STR_PAD_BOTH);
?>
Related examples in the same category