PHP str_pad() function

In this article, We will explain to you PHP str_pad() function with example.

PHP str_pad() function

The str_pad() function is a string function. which is used to add pad a string of string. so you can see our PHP String Function example.



Paramerter Option

stringThis is Required Paramerter and use the string
lengthThis is Required Paramerter. Total number of length after add padding
pad_stringThis is Optional Paramerter. You can Specifies the string otherwise use default whitespace
pad_typeThis is Optional Paramerter. there are three types of pad values like as STR_PAD_BOTH, STR_PAD_LEFT and STR_PAD_RIGHT


    $str = "This is My website";
    echo str_pad($str,20,"."); echo "
"; echo str_pad($str,20,".",STR_PAD_LEFT); ?>


This is My website..
..This is My website