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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:36:20+00:00 2026-06-13T15:36:20+00:00

I have a one core php file in which i want to get file

  • 0

I have a one core php file in which i want to get file name in a particular folder with order like,
I have many files but each file name like filename_0,filename_1,filename_2 like this so when ever i fetch file name in folder that is not proper order and i am getting filename_0,filename_2,filename_1..

    $dir_path="/var/lib/myproject";
        $folder=dir("$dir_path");
                    $j=0;$allfilename='';
                    while($folderEntry=$folder->read())
                    {
                        if($folderEntry == '.' || $folderEntry == '..' )
                        {
                        continue;
                        }else{
echo "Path of directory is>>>>>>>>".$folderEntry;
                        $allfilename[]=$folderEntry;
                        $j++;
                        }
                    }
  $folder->close();

i can fetch file name but not getting order so any order loke incremented filename_0 to continue file name …..
so can any one any idea how to get file name with ascending order.

  • 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-13T15:36:21+00:00Added an answer on June 13, 2026 at 3:36 pm

    You can always natsort the filename array.

    natsort($allfilename);
    

    Note here natural sort is necessary as you might want to consider filename_1 is before filename_100. Another option is using sort function.

    sort($allfilename, SORT_NATURAL);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this test Core Data project, I have a one to many relationship from
I have several objects set up in Core Data, one of which is Deck
I have 2 projects. One project is a core and contains the GUI which
have one time consuming step that flattens a bunch of files. basically i'd like
I have changed the Configure::write('Security.salt', '############'); value in the file config/core.php file to a
I'm new to doctrine. I created an bootstrap file like the following one: require_once(dirname(__FILE__)./../conf/general.php);
I have copied app/code/core/Mage/Checkout/controllers/OnepageController.php to app/code/local/Mage/Checkout/controllers/OnepageController.php and overrided one function. I have also refreshed
I currently have the following in one solution: Core Project (data access, biz logic,
I am having a Core Data problem with NSFetchedResultsController . I have a one
I was learning Core Data and previously I have used SQLite in one of

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.