PHP str_pad Function
What is str_pad Function?
Explanation
In PHP, This function is used to pad a string to a certain length with another string.
Syntax:
str_pad(string,length,pad_string,pad_type)
This functions returns the input string padded on the left, the right, or both sides to the specified padding length. If the optional argument pad_string is not supplied, the input is padded with spaces, otherwise it is padded with characters from pad_string up to the limit.
Example :
<?php
$str = "Hiox India";
echo str_pad($str,20,".",STR_PAD_BOTH);
?>
Result :
.....Hiox India.....
In the above example "Hiox India" is padded on both sides with the character "." and the total length of the character is "20".