-
-
Save mnpenner/1e35f9f20d0982c541c6ea1fd45ff5a8 to your computer and use it in GitHub Desktop.
starts with + ends with functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class Str { | |
public static function StartsWith($haystack, $needle, $case_insensitive=false) { | |
if($case_insensitive) { | |
$haystack = strtolower($haystack); | |
$needle = strtolower($needle); | |
} | |
return substr($haystack, 0, strlen($needle)) === $needle; | |
} | |
public static function EndsWith($haystack, $needle, $case_insensitive=false) { | |
if($case_insensitive) { | |
$haystack = strtolower($haystack); | |
$needle = strtolower($needle); | |
} | |
return substr($haystack, -strlen($needle)) === $needle; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment