Jump to content

Archived

This topic is now archived and is closed to further replies.

ibanez270dx

Unlinking *.whatever

Recommended Posts

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

Share this post


Link to post
Share on other sites
Use the glob() function to generate an array of all .xls files in a folder.

Loop through the array and unlink each one separately.

Share this post


Link to post
Share on other sites
try this.

[code=php:0]
$dir = "path/to/folder";

foreach (glob($dir . "*.xls") as $files) {
    unlink($files);
}
[/code]

Hope this helps,
Tom

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.