Reputation: 6697
The result of this code:
echo trim('سلام؟', '؟');
Is �لام
.
Why? I don't even know what's �
supposed to be. Where does that come from?
Upvotes: 1
Views: 79
Reputation: 646
rtrim
is to replace from the right side of the string and it is OK for OP's requirement. But I think str_replace()
is more appropriate. Trim can be done by it, also helpful to replace from any position of string. An example:
$search = ['؟', ' ',]; // Add more elements if required
$str = 'سلام؟';
$output = str_replace($search, '', $str);
echo $output;
Output:
سلام
Upvotes: 0
Reputation: 28529
Your string char is arabic, which is in the reverse order. So you have to use rtrim().
Upvotes: 0
Reputation: 1578
You can use rtrim()
.
This will remove white space from end of the string.
echo rtrim('سلام؟', '؟');
And your problem solved..
Upvotes: 0
Reputation: 9654
I think this is because it is right-toleft- language, You can use rtrim()
phpFiddle - Hit "Run F9" to execute
echo rtrim('سلام؟', '؟');
Upvotes: 1