Last active
May 2, 2024 02:43
-
-
Save gdarko/5dbcf96dccb2a3eece6c10d084d008af to your computer and use it in GitHub Desktop.
str_contains() was introduced in PHP8. This is a polyfill for PHP7 or lower.
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 | |
if (!function_exists('str_contains')) { | |
/** | |
* Check if substring is contained in string | |
* | |
* @param $haystack | |
* @param $needle | |
* | |
* @return bool | |
*/ | |
function str_contains($haystack, $needle) | |
{ | |
return (strpos($haystack, $needle) !== false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!