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:
parent
725a472880
commit
477e065375
1 changed files with 9 additions and 0 deletions
9
core.php
9
core.php
|
@ -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.
|
||||||
|
|
Loading…
Reference in a new issue