Web >> Development >> PHP >> How to do an OR match of few words

example to match w3p_nnnnn.html or w3p_nnnnn.dir, match of either html or dir is stored into filematches[2] if ( preg_match("/^w3p[_](\d+)[.]((html)|(dir))/i",$file,$filematches) ) { $ID = $filematches[1]; $filetype = $filematches[2]; print "$ID, $filetype\n"; }