The standard PHP way to test whether a string $str ends with a substring $test is:
$str
$test
$endsWith = substr( $str, -strlen( $test ) ) ==
for single-char needle:
if (@strrev($haystack)[0] == $needle) { // yes, it ends... }