1
2
3
4
5
6
7
8
9
function endsWith($haystack, $needle)
{
   $length = strlen($needle);
   if ($length == 0) {
       return true;
   }

   return (substr($haystack, -$length) === $needle);
}