Last active
May 10, 2016 09:26
-
-
Save itsliamjones/b5012ddc38541abcb40ba9e5a8620382 to your computer and use it in GitHub Desktop.
Test to see if string contains ALL needles
This file contains hidden or 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 | |
/** | |
* Test to see if string contains ALL needles | |
* | |
* @param array $needles | |
* @param string $haystack | |
* | |
* @return boolean | |
*/ | |
function stringContains(array $needles, $haystack) | |
{ | |
return array_intersect($needles, explode(" ", $haystack)) === $needles; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment