Reputation: 411
I learned that unlink in PHP will remove the files in your directory as:
unlink(/usr/local/datas/APRIL_Delivery.txt)
But what if you want to remove all the files where the beginning of the file name is specific. For example APRIL:
APRIL_Delivery_1.txt
APRIL_Delivery_2.txt
APRIL_Delivery_3.txt
MAY_Delivery_3.txt
I want to remove all the files with APRIL month and keep the file with MAY month. And Now I'm here to get some ideas on how to do it.
Are there any suggestions for this? Any comments would be much appreciated :-)
Upvotes: 0
Views: 513
Reputation: 4637
Try this code:
$filename = 'prefix*.*'; //yourprefix
array_map('unlink', glob($filename));
Upvotes: 1