I need to have a string that has a specified length and replace the excess characters with a letter.
e.g.
My original string is : “JOHNDOESMITH”. The length should be up to 25 characters only.
I need my string to become “XXXXXXXXXXXXXJOHNDOESMITH” (13 X’s and 12 chars from the original string).
Anybody please tell me how to achieve this? Is there a string function for this? I’ve been racking my brains out for quite some time now and I still can’t find a solution.
You could use
str_pad()to do it…CodePad.
You could use
str_repeat()to do it…CodePad.
You can always run
substr($str, 0, 25)to truncate your string to the first 25 characters.