carmi Posted November 28, 2011 Share Posted November 28, 2011 Hi Gusy, Would be great if you can help me to sort this out and Thank you in advance. I would like to hide all files with "swf" extension from my file and folder directory, I know how to hide one specific file but not ll files with same extension. For example: *.swf. Here is my code which is work for full file names but not all files with same extension. <?php $filearray = array(); if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != ".htaccess" && $file != "index.php" && $file != "style.css" && $file != "Images" && $file != "*.swf" && $file != "index.html") { $filearray[] = $file; } } closedir($handle); natcasesort($filearray); foreach($filearray as $f) { $thelist .= '<img width="15" height="15" alt="[DIR]" src="/Images/folder.jpg"> <a href="'.$f.'">'.$f.'</a> '; } } ?> As you can see I have "&& $file != "*.swf"" which need your advise in this part. I just want people not seeing all .SWF files in the index directory of my server. I have already have index.html inside my folder as well which has been hided because of "$file != "index.html"". But this is not hiding my ".SWF" files. Many Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/251950-hide-all-files-with-same-extension-in-php-file-directory/ Share on other sites More sharing options...
WebStyles Posted November 28, 2011 Share Posted November 28, 2011 instead of $file != "*.swf" you can use something like !strpos($file,".swf") check you strpos hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/251950-hide-all-files-with-same-extension-in-php-file-directory/#findComment-1291852 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.