regex - How to check for two words ('goat' and 'sheep') with preg_match in PHP? -


how check 2 words (example 'sheep' , 'goat') preg_match in php?

example:

if (!preg_match(goat|sheep)) header(' location: / '); 

thanks!

simply this:

if (!preg_match('~\b(?:goat|sheep)\b~i', $yourstring)) header('location: /'); 

more informations here , here


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -