Answers for "How To Check If A String Ends With Another String In PHP"

PHP
0

How To Check If A String Ends With Another String In PHP

function endsWith($haystack,$needle,$case=true) {
    //If its case specific
    if($case){
      return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);
    }
    return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);
}
Posted by: Guest on September-22-2021

Code answers related to "How To Check If A String Ends With Another String In PHP"

Browse Popular Code Answers by Language