bilis_money Posted March 18, 2008 Share Posted March 18, 2008 Hi guys Let say i have 5 files and all of them has the .swf extension filename. now how do i delete them properly by just calling one statement? i tried the code below but it did not work. <?php unlink("*.swf"); ?> thank you in advance. Quote Link to comment Share on other sites More sharing options...
Cep Posted March 18, 2008 Share Posted March 18, 2008 You cannot do a batch deletion with a wildcard using the unlink method, you must loop through the files you wish to delete. Quote Link to comment Share on other sites More sharing options...
moon 111 Posted March 18, 2008 Share Posted March 18, 2008 This should work: <?php $dir = './dir/'; // The directory must have '/' at the end! $arr = scandir($dir); foreach($arr as $value) { if(strstr($value, '.swf')) { unlink($dir . $value); } } ?> Quote Link to comment Share on other sites More sharing options...
bilis_money Posted March 18, 2008 Author Share Posted March 18, 2008 can you show me some example codes please. thank you. 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.