echo str_pad("plus2net.com",15,"*");//output: plus2net.com***
echo str_pad("plus2net.com",15,"*",STR_PAD_LEFT);//output: ***plus2net.com
echo str_pad("plus2net.com",15,"*",STR_PAD_BOTH);//output: *plus2net.com**
Syntax
str_pad ( $input_str, $length, $pad_string, pad_type)
Parameters | DESCRIPTION |
---|---|
$input_str | Required : Input string |
$length | Required : If $length is less than , zero or equal to length of Input string then no padding takes place and $input_string is returned |
$pad_string | Optional : To be used as padding. If not given blank space is used. Padding is done upto the limit. |
pad_type | Optinoal: Which side padding is to be added STR_PAD_RIGHT ( default ) STR_PAD_LEFT STR_PAD_BOTH |
$str="Welcome to Plus2net.com ASP Section to learn web programing";
$ar=explode(" ",$str);
while (list ($key, $val) = each ($ar)) {
echo str_pad($val,15,"-",STR_PAD_RIGHT);
echo "<br>";
}
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.