Mega Code Archive

 
Categories / Php / Strings
 

Str_pad() function pads string to length pad_length with a specified characters

Its syntax is: string str_pad (string input, int pad_length [, string pad_string [, int pad_type]]) If pad_string is not specified, string will be padded with blank spaces.  pad_type may be assigned STR_PAD_RIGHT, STR_PAD_LEFT, or STR_PAD_BOTH This example shows how to pad a string using str_pad() defaults: <? $food = "salad"; print str_pad ($food, 5);     ?>