Skip to content

Instantly share code, notes, and snippets.

@dellow
Last active September 20, 2022 03:27
Show Gist options
  • Save dellow/f961f3274ba9bd3b55fa to your computer and use it in GitHub Desktop.
Save dellow/f961f3274ba9bd3b55fa 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