I have a string with, for example, 32 characters. For first, i want to establish that the string have max 32 characters and i want add blank spaces if characters is only, for example, 9.
Example:
ABCDEFGHI ---> 9 characters
I want this:
ABCDEFGHI_______________________ ---> 9 characters + 23 blank spaces added automatically.
The function you are looking for is
str_pad.http://php.net/manual/de/function.str-pad.php
The default pad string already is blank spaces.
As your maximum length should be 32 and
str_padwon’t take any action when the string is longer than 32 characters you might want to shorten it down usingsubstrthen:http://de.php.net/manual/de/function.substr.php
This again won’t take any action if your string is exactly 32 characters long, so you always end up with a 32 characters string in
$resultnow.