Skip to content

Instantly share code, notes, and snippets.

@Cloud-Dark
Forked from dellow/array_contains.php
Created September 20, 2022 03:27
Show Gist options
  • Save Cloud-Dark/eefa21bea35877b00c5eaae7927b5909 to your computer and use it in GitHub Desktop.
Save Cloud-Dark/eefa21bea35877b00c5eaae7927b5909 to your computer and use it in GitHub Desktop.
Check if string contains word from array.
/**
* array_contains
* Check if string contains word from array.
*
* @since 1.0.0
* @version 1.0.0
**/
function array_contains($str, array $arr){
foreach($arr as $a){
if(stripos($str, $a) !== false) return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment