Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7417971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:47:57+00:00 2026-05-29T07:47:57+00:00

In short We have a a file called clients.(unique parameter) . And now we

  • 0

In short

We have a a file called clients.(unique parameter). And now we want to unlink() it, but as we don’t know the file extension, how do we succeed?

Longer story

I have a cache system, where the DB query in md5() is the filename and the cache expiration date is the extension.

Example: 896794414217d16423c6904d13e3b16d.3600

But sometimes the expiration dates change. So for the ultimate solution, the file extension should be ignored.

The only way I could think of is to search the directory and match the filenames, then get the file extension.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:47:58+00:00Added an answer on May 29, 2026 at 7:47 am

    Use a glob():

    $files = glob("/path/to/clients.*");
    foreach ($files as $file) {
      unlink($file);
    }
    

    If you need to, you can check the filemtime() of each file returned by the glob() to sort them so that you only delete the oldest, for example.

    // Example: Delete those older than 2 days:
    $files = glob("./clients.*");
    foreach ($files as $file) {
       if (filemtime($file) < time() - (86400 * 2)) {
         unlink($file);
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file, which change it content in a short time. But I'd
I have a very short (so far), very basic XML file called config.xml like
In short, I have a 20,000,000 line csv file that has different row lengths.
I have a file temp.txt, that I want to sort with the sort command
I have an input file that I want to sort based on timestamp which
I have an XML file that is very long, but here is a shot
I have a huge tab separated file which I want to sort on its
I have a Service that downloads a file from the internet. What I want
Folks, I have a HTML file which contains a button called Email this content
I have a servlet file called NewServlet.java . This servlet is called by my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.