$destination ="Hong Kong "
I want to remove the last space to become like this
$destination ="Hong Kong"
trim removes the characters at the beginning and end of the string.
ltrim, only those at the beginning of the string.
rtrim those at the end of the string.
In your case to delete the last space, you can do so :
$destination = rtrim("Hong Kong "); //prints "Hong Kong"
Answered By – Jedupont