Php – How to get the last char of a string in PHP

PHPstring

I need to get the last character of a string.
Say I have "testers" as input string and I want the result to be "s". how can I do that in PHP?

Best Answer

substr("testers", -1); // returns "s"

Or, for multibytes strings :

substr("multibyte string…", -1); // returns "…"