How to do if in the text there are certain words that derive limit is 18?

There is here such code:

if(preg_match("~\s*18\s*~u", $groupInfo[0]['name'])) 
 $plus18 = "<img src="\"/images/18plus.png\"" style="\"position:" relative;top: -16px;padding-left: 3px;width: 25px;\" width="\"25px\"" data-toggle="\"tooltip\"" data-original-title="\"This" mark means that the community has an age restriction of 18+\">";
else $plus18 = "";


Everything works well, if the title is "18" it displays the mark of 18+ automatically. How to do a few words here? That is, for example I want to add the words: dirty, sex, intimacy, etc.
June 10th 19 at 16:57
2 answers
June 10th 19 at 16:59
Solution
preg_match("~\s*(18|vulgar|sex|sex)\s*~u", .....
Thank you - ludie commented on June 10th 19 at 17:02
June 10th 19 at 17:01
(vulgar|sex|sex)

Find more questions by tags PHP