You can utilize the PHP rtrim() capacity to strip whitespace from the finish of a string.
SOLUTION:
rtrim
(PHP 4, PHP 5, PHP 7)
rtrim - Remove spaces (or different characters) from end of string
Description
rtrim (string $ str [, string $ character_mask]): string
Returns the string str, in the wake of erasing all the clear characters (or different characters) toward the finish of the string.
Called without the subsequent parameter, rtrim () will erase the accompanying characters:
We should look this exemple:
Example
$my_str = 'Hello World! ';
echo strlen($my_str); // Outputs: 16
$trimmed_str = rtrim($my_str);
echo strlen($trimmed_str); // Outputs: 12
if you want to improve the solution
comment to help the community
Post a Comment