You can use str_pad()
to do this ...
echo str_pad($str, 25, 'X', STR_PAD_LEFT);
CodePad
You can use str_repeat()
to do this ...
echo str_repeat('X', max(0, 25 - strlen($str))) . $str;
CodePad
The length should be no more than 25 characters.
You can always run substr($str, 0, 25)
to trim the string to the first 25 characters.
source share