nrg_alpha Posted August 26, 2008 Share Posted August 26, 2008 So it would be like this: if (preg_match('#Theme\.php$#', $file)) { include ($file); } Yep, that should do it. If you want the match to be case insensative, you can simply add the i modifier after the last delimiter like so: if (preg_match('#Theme\.php$#i', $file)) That way, whether the file is Theme.php or theme.php or THEME.PHP.. it won't matter. Lastly, incase you are wondering about the escaped period (\.) instead of just a period is because the period acts as a wild card (it means any character..(althought in reality I don't think it includes newlines)). So if you had: if (preg_match('#Theme.php$#i', $file)) The unescaped period acts as a wildcard and as a result can match stuff like: Theme_php, Theme-php, Theme*php, Themexphp, etc.. so by escaping the period with a backslash, that wildcard metacharacter looses its meaning and simply becomes a period (thus, only theme.php can be matched). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.