1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-26 05:32:59 +00:00

Add startsWith to core

This commit is contained in:
Starbeamrainbowlabs 2017-04-17 13:00:40 +01:00
parent 725a472880
commit 477e065375

View file

@ -363,6 +363,15 @@ function mb_stripos_all($haystack, $needle) {
return false; return false;
} }
/**
* Tests whether a string starts with a specified substring.
* @param string $haystack The string to check against.
* @param string $needle The substring to look for.
* @return bool Whether the string starts with the specified substring.
*/
function startsWith($haystack, $needle) {
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
}
/** /**
* Tests whether a string ends with a given substring. * Tests whether a string ends with a given substring.
* @param string $whole The string to test against. * @param string $whole The string to test against.