<?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;
}
-
-
Save gavrya/1ed1b00c373b9759dc1d 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