String parsing: As long as all words are present, ignore order
This code below works prefectly as long as the $string, contains any of the strings exactly as in the array. But what if the $string has "camera digital" or "player dvd" (same words, but different order from the array) how can I alter the regex to make itmatch as long all the words are there, independent of the order?
PHP Code:
$product_array[] = "stereo";
$product_array[] = "dvd player";
$product_array[] = "digital camera";
foreach($product_array as $one_product)
{
if (preg_match("/$one_product/i", $string, $matches, PREG_OFFSET_CAPTURE))
{
return $matches[0];
}
}
Thank you for any input....