<?php
function startsWith($haystack, $needle)
{
return strncmp($haystack, $needle, strlen($needle)) === 0;
}
function endsWith($haystack, $needle)
{
return $needle === '' || substr_compare($haystack, $needle, -strlen($needle)) === 0;
}
Created
April 8, 2014 05:40
-
-
Save umidjons/10094793 to your computer and use it in GitHub Desktop.
PHP: startsWith & endsWith functions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment