With the help of the staff here in the stack, I've set up a function where I treat a string.
I'll post the code and explain the problem.
Function:
function mb_str_pad($input, $pad_length, $pad_string = ' ', $pad_type = STR_PAD_RIGHT, $encoding = "UTF-8") {
$diff = strlen($input) - mb_strlen($input, $encoding);
return str_pad($input, $pad_length + $diff, $pad_string, $pad_type);
}
Example, when I call the function like this:
echo mb_str_pad("ESPERANÇA", 15, "#");
It returns me:
ESPERANÇA######
Well the problem starts when you put a word that contains more than 15 letters, I need it to cut the word. Example of how to stay:
echo mb_str_pad("ESPERANÇAaaaaaaaaaaa", 15, "#");
It has to return like this:
ESPERANÇAaaaaaa
In other words, if he goes over 15 characters he has to cut and ignore everything on the right.
Can anyone help me with this?