From 477e065375970558e74ee9c8fa3937d72e65e1bc Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 17 Apr 2017 13:00:40 +0100 Subject: [PATCH] Add startsWith to core --- core.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core.php b/core.php index 8437e3f..cb40609 100644 --- a/core.php +++ b/core.php @@ -363,6 +363,15 @@ function mb_stripos_all($haystack, $needle) { 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. * @param string $whole The string to test against.