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 8271993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:59:33+00:00 2026-06-08T06:59:33+00:00

So I have this app that processes CSV files. I have a line of

  • 0

So I have this app that processes CSV files. I have a line of code to load the file.

$myFile = "data/FrontlineSMS_Message_Export_20120721.csv";  //The name of the CSV file
$fh = fopen($myFile, 'r');                             //Open the file

I would like to find a way in which I could look in the data directory and get the newest file (they all have date tags so they would be in order inside of data) and set the name equal to $myFile.

I really couldn’t find and understand the documentation of php directories so any helpful resources would be appreciated as well. Thank you.

  • 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-06-08T06:59:35+00:00Added an answer on June 8, 2026 at 6:59 am

    Here’s an attempt using scandir, assuming the only files in the directory have timestamped filenames:

    $files = scandir('data', SCANDIR_SORT_DESCENDING);
    $newest_file = $files[0];
    

    We first list all files in the directory in descending order, then, whichever one is first in that list has the “greatest” filename — and therefore the greatest timestamp value — and is therefore the newest.

    Note that scandir was added in PHP 5, but its documentation page shows how to implement that behavior in PHP 4.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this c# web app that relies heavily on two dll files that
I have this iPad app using Storyboard. There are some file that are marked
At this moment I have an application that processes a file. My workflow is:
I have multiple app processes that each connect to servers and receive data from
We have a Swing app that processes relatively large amounts of data. For instance
I have this RoR app that calls to RAILS_ROOT. When running it using rails
I copied this class from a similar class I have in this app that
I have this method in App Delegate that makes a window and content view
I have a simple GAE app that includes a login/logout link. This app is
I have an App that downloads and displays images from URL's. This works fine

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.