str_pad() function in php
str_pad()
is a built-in PHP function that pads a string to a certain length with another string. It takes three arguments:
- The input string to be padded.
- The length of the resulting padded string.
- The string to use for padding (optional, defaults to space character).
The function returns the padded string.
Here's an example usage:
$input = "hello";
$padded = str_pad($input, 10, "-");
echo $padded; // Output: "hello-----"
In this example, the input string "hello" is padded with "-" characters to a length of 10. The resulting padded string is "hello-----".