php preg_match, matching when 2 words might come in random sequence

后端 未结 2 863
一个人的身影
一个人的身影 2021-01-24 06:57

Is it possible to match two words that might come in random sequences? Examples:

$title = \"2 pcs watch for couple\";
$title = \"couple watch 2 pcs\";

2条回答
  •  佛祖请我去吃肉
    2021-01-24 07:19

    If you're just testing for the presence of the two words in the string you could use

    '/couple.*2 pcs|2 pcs.*couple/' 
    

提交回复
热议问题