Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

startsWith() and endsWith() functions in PHP

function startsWith($haystack, $needle)
{
     $length = strlen($needle);
     return (substr($haystack, 0, $length) === $needle);
}

function endsWith($haystack, $needle)
{
    $length = strlen($needle);
    if ($length == 0) {
        return true;
    }

    return (substr($haystack, -$length) === $needle);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #functions #PHP
ADD COMMENT
Topic
Name
3+8 =