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. Link to comment https://forums.phpfreaks.com/topic/6595-excluding-files-with-in-them/ 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] Link to comment https://forums.phpfreaks.com/topic/6595-excluding-files-with-in-them/#findComment-23932 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! Link to comment https://forums.phpfreaks.com/topic/6595-excluding-files-with-in-them/#findComment-23936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.