diff --git a/src/MD_STD.php b/src/MD_STD.php index 1e6b91e..b16e1ea 100644 --- a/src/MD_STD.php +++ b/src/MD_STD.php @@ -174,6 +174,39 @@ final class MD_STD { } + /** + * Function checking if a string contains another in a case-insensitive way. + * + * @param string $haystack String to check. + * @param string $needle Potential start of $haystack. + * + * @return boolean + */ + public static function stri_contains(string $haystack, string $needle):bool { + + if (stripos($haystack, $needle) === false) return false; + return true; + + } + + /** + * Function checking if a string contains any of a given set of strings in a + * case-insensitive way. + * + * @param string $haystack String to check. + * @param string[] $needles Potential values contained in haystack. + * + * @return boolean + */ + public static function stri_contains_any(string $haystack, array $needles):bool { + + foreach ($needles as $needle) { + if (self::stri_contains($haystack, $needle) === true) return true; + } + return false; + + } + /** * Type-safe(r) wrapper around preg_replace. *