Questions:

Can I use a wildcard in unlink - ie: $myfile = '../pdf/'.$tnum .'*.pdf';

This results in an error:
Warning: unlink(../pdf/36818*.pdf) [function.unlink]: No error in \purgepdf.inc.php on line 29

Any help would be greatly appreciated.

Thanks,
Bill

Recommended Answers

All 3 Replies

See: http://php.net/manual/en/function.unlink.php

There are a number of posts about recursive deletes. In answer to your question: it looks as if the unlink won't recursively delete with wildcards. You need additional code.

Member Avatar for diafol

How about this?

$pattern = "*.pdf";
array_map("unlink", glob($pattern));

That will delete all pdfs from the current directory. You can add locations and other file patterns to the $pattern var - BUT - do not place any whitespace between comma separated values.

Thanks, I will give it a try.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.