Ok lets say I whant to match 3 words in a sentence... but I neet to match them in any order, for example:
$sentences = Array(
"one two three four five six seven eight nine ten",
"ten nine eight seven six five four three two one",
"one three five seven nine ten",
"two four six eight ten",
"two ten four six one",
);
So I need to match the words "two", "four" & "ten", but in any order and they can or not have any other words between them. I Try
foreach($sentences AS $sentence) {
$n++;
if(preg_match("/(two)(.*)(four)(.*)(ten)/",$sentence)) {
echo $n." matched\n";
}
}
But this will match ONLY sentence 1 and I need to match in sentence 1,2,4 & 5.
I hope you can help... Regards! (and sorry for my english)