How can I check if a string ends with a certain substring in PHP? Example code: - Biz Tech

How can I check if a string ends with a certain substring in PHP? Example code:

Listen
$string = "The quick brown fox jumps over the lazy dog";

if (substr($string, -3) == "dog") {
    echo "The string ends with 'dog'";
} else {
    echo "The string does not end with 'dog'";
}