ibanez270dx Posted August 14, 2006 Share Posted August 14, 2006 Hi, I'm trying to do an unlink command like so: unlink(*.xls) . It doesn't work and I have tried it with single and double quotes. Can anyone help me? Thanks! - Jeff Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 14, 2006 Share Posted August 14, 2006 Use the glob() function to generate an array of all .xls files in a folder.Loop through the array and unlink each one separately. Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 14, 2006 Share Posted August 14, 2006 try this.[code=php:0]$dir = "path/to/folder";foreach (glob($dir . "*.xls") as $files) { unlink($files);}[/code]Hope this helps,Tom Quote Link to comment Share on other sites More sharing options...
tomfmason Posted August 14, 2006 Share Posted August 14, 2006 You have to be careful with this. It will delete all of the files with the ext of xls in that folder and all sub folders. Quote Link to comment Share on other sites More sharing options...
ibanez270dx Posted August 14, 2006 Author Share Posted August 14, 2006 Thanks! I used this:[code=php:0]foreach (glob("*.xls") as $filename) { unlink($filename); }[/code]It works perfectly. And yes, I did need to delete all the files with a *.xls extension. 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.