If you pass substr() a negative number, it counts from the end of the string.
<?php $test = "this is a test."; if ( $test = substr( $test, -3 ) == "est") { print "est"; } else { print "Welcome to our shop!"; } ?>