$string = 'boo-hello--word';
$array = array(
"boo - hello",
"boo - hello world",
"boo - hello world foo",
);
...
foreach ($array as $element) {
if (string_contains_all_words($string, $element) {
// True
$match = $element; // this should be "boo hello world"
}
}
As (hopefully) the php illustrates above, I have a string with a mixed number of dashes (sometimes one, maybe two). I want to search in an array to see if all words (and only ALL words) (excluding the dashes) exists.