Is there an expert here wih Preg_match_all?

Hi,

I found this code here :

$keywordStr = "gaming notebook";
$string = "Which notebook for good gaming performance,it's my notebook";
$keywords = explode(" ", $keywordStr);
$parts = implode("|", $keywords);

preg_match_all("/\b$parts\b/i", $string, $matches);
// matched items should contain all needed keywords
if (count($keywords) == count(array_intersect($keywords, $matches[0]))) {
    echo "Jep, keyword combination is in string";
} else {
    echo "No, keyword combination is not in string";
}

It’s perfect for my problem but i need a little update.

Also, I want to check an address in a form user, from an address list.

Example, my address is : 2172, street blue martin

I my data list I have those address :

215 street paris
2172 blue martin
1 place caron

Below script it’s good, but I want to check also order of each word.

Do you have an idea ?

Example with my data list, this address “2172, street blue martin” is good, but “2172, street martin blue” is bad

Can you help me ?

Thanks

Finaly, it was too easy :

$regex = '/\b'.implode('\b.+?\b', array_map('preg_quote', $keywords)).'\b/i';
$find = preg_match($regex,$address);