How to get the last char of a string in PHP?
Or by direct string access:
$string[strlen($string)-1];
Note that this doesn't work for multibyte strings. If you need to work with multibyte string, consider using the mb_*
string family of functions.
As of PHP 7.1.0 negative numeric indices are also supported, e.g just $string[-1];