Created
December 11, 2022 07:19
-
-
Save AucT/13a74e9fdc9cee8cfbae7e734387c725 to your computer and use it in GitHub Desktop.
str_icontains and case-insensitive str_icontains
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 | |
// Polyfill for PHP 4 - PHP 7, safe to utilize with PHP 8 | |
if (!function_exists('str_contains')) { | |
function str_contains (string $haystack, string $needle) | |
{ | |
return empty($needle) || strpos($haystack, $needle) !== false; | |
} | |
} | |
// case-insensitive str_icontains | |
if (!function_exists('str_icontains')) { | |
function str_icontains (string $haystack, string $needle) | |
{ | |
return empty($needle) || stripos($haystack, $needle) !== false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment