Twentyoneth Posted April 4, 2006 Share Posted April 4, 2006 im trying to only include files from a certain directory that dont include "-" in the filename.so:opendir($dir);$files = readdir($dir);closedir($dir);How do I say "except '-' "? I dont know where to start. Quote Link to comment Share on other sites More sharing options...
obsidian Posted April 4, 2006 Share Posted April 4, 2006 try something like this:[code]<?phpif ($handle = opendir($pathToFiles)) { while (false !== ($file = readdir($handle))) { if (!preg_match('|-|', $file)) { // there is no '-' in the name include("$pathToFiles/$file"); } } closedir($handle);}?>[/code] Quote Link to comment Share on other sites More sharing options...
Twentyoneth Posted April 4, 2006 Author Share Posted April 4, 2006 Perfect, works exactly how I need it to, thanks a ton! 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.