Created
March 1, 2013 12:42
-
-
Save snetty/5064384 to your computer and use it in GitHub Desktop.
easy to remember string search 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
function contains($haystack, $needle){ | |
return strpos($haystack, $needle) !== false; | |
} | |
function begins_with($haystack, $needle){ | |
return strpos($haystack, $needle) === 0; | |
} | |
function ends_with($haystack, $needle){ | |
return strlen($haystack) - strlen($needle) === strrpos($haystack,$needle); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment