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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:26:16+00:00 2026-05-31T19:26:16+00:00

I have a number of files I am loading into a slideshow, I have

  • 0

I have a number of files I am loading into a slideshow, I have them numbered by the client in the order that they’d like to be displayed.

I’m grabbing them with glob $pics = glob("images/slideshow/*.jpg", GLOB_NOSORT); but for some reason I’m getting the old Windows sorting bug, of 11 being sorted above 2.

For example,

Array
(
    [0] => images/slideshow/1.jpg
    [1] => images/slideshow/14.jpg
    [2] => images/slideshow/15.jpg
    [3] => images/slideshow/16.jpg
    [4] => images/slideshow/18.jpg
    [5] => images/slideshow/2.jpg
    [6] => images/slideshow/20.jpg
    [7] => images/slideshow/21.jpg
    [8] => images/slideshow/22.jpg
    [9] => images/slideshow/23.jpg
    [10] => images/slideshow/24a.jpg
    [11] => images/slideshow/25.jpg
    [12] => images/slideshow/26.jpg
    [13] => images/slideshow/29.jpg
    [14] => images/slideshow/3.jpg
    [15] => images/slideshow/36.jpg
    [16] => images/slideshow/38.jpg
    [17] => images/slideshow/4.jpg
    [18] => images/slideshow/40.jpg
    [19] => images/slideshow/41.jpg
    [20] => images/slideshow/5.jpg
    [21] => images/slideshow/6.jpg
    [22] => images/slideshow/7.jpg
)

I’ve run it through asort() and I can’t seem to find out why this isn’t working, short of it being something about them being strings, rather than strictly numbers.

  • 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-31T19:26:18+00:00Added an answer on May 31, 2026 at 7:26 pm

    Check out natsort:

    This function implements a sort algorithm that orders alphanumeric
    strings in the way a human being would while maintaining key/value
    associations.

    $array2 = array("img12.png", "img10.png", "img2.png", "img1.png");
    
    print_r($array2);
    
    Array
    (
        [3] => img1.png
        [2] => img2.png
        [1] => img10.png
        [0] => img12.png
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large number of csv files that look like this below: xxxxxxxx
I have a number of source files I want to agglomerate into a .a
I have a number of data files to process from a data warehouse that
I have a number of large data files that I included in projects attributed
I have developed a Java program that will count the number of files in
When I use javascript_include_tag or stylesheet_link_tag to include files, they have a number at
I am trying to rbind a large number of csv files that have many
I have text files with a lot of uniform rows that I'd like to
I have a number of .css files spread across some directories. I need to
I have a number of ~10MB xml files on a local computer. For each

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.