Search code examples
phptrim

Why trim() affects on the other characters?


The result of this code:

echo trim('سلام؟', '؟');

Is �لام.

Why? I don't even know what's supposed to be. Where does that come from?


Solution

  • I think this is because it is right-toleft- language, You can use rtrim()

    phpFiddle - Hit "Run F9" to execute

    echo rtrim('سلام؟', '؟');