<?php// check if string ends with specific sub-stringfunction endsWith($currentString, $target){ $length = strlen($target); if ($length == 0) { return true; } return (substr($currentString, -$length) === $target);} $mystr="Test String"; if(endsWith($mystr,"ing")) echo "String ends with 'ing'"; else echo "String doesn't end with 'ing'"; ?>