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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:38:00+00:00 2026-06-15T08:38:00+00:00

I have a really big array containing the following data: Array ( [2] =>

  • 0

I have a really big array containing the following data:

Array
(
    [2] => Array
        (
            [Berlin] => Array
                (
                    [1] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [name] => Joe
                                    [car_name] => Audi
                                    [car_color] => Black
                                    [sid] => 130 
                                )
                            [1] => stdClass Object
                                (
                                    [name] => Mark
                                    [car_name] => BMW
                                    [car_color] => Red
                                    [sid] => 135
                                )
                        )
                    [0] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [name] => Lucas
                                    [car_name] => Audi
                                    [car_color] => Yellow
                                    [sid] => 168
                                )
                            [1] => stdClass Object
                                (
                                    [name] => Joe
                                    [car_name] => Volkswagen
                                    [car_color] => Black
                                    [sid] => 170 
                                )
                            [2] => stdClass Object
                                (
                                    [name] => Thomas
                                    [car_name] => Ford
                                    [car_color] => Gray
                                    [sid] => 119
                                )
                        )
                )
            [Moscow] => Array
                (
                    [1] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [name] => Matt
                                    [car_name] => Mustang
                                    [car_color] => Black
                                    [sid] => 230 
                                )
                            [1] => stdClass Object
                                (
                                    [name] => Suze
                                    [car_name] => Lada
                                    [car_color] => Red
                                    [sid] => 245
                                )
                        )
                    [0] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [name] => Lucas
                                    [car_name] => Unknown
                                    [car_color] => Brown
                                    [sid] => 374
                                )
                            [1] => stdClass Object
                                (
                                    [name] => Mathew
                                    [car_name] => Volkswagen
                                    [car_color] => Blue
                                    [sid] => 589 
                                )
                            [2] => stdClass Object
                                (
                                    [name] => Thomas
                                    [car_name] => Ford
                                    [car_color] => Light Blue
                                    [sid] => 741
                                )
                        )
                )
        )
)

Now I would like to sort it like this (please read the // lines):

Array
(
    [2] => Array //from min to max - eg. from 0 to 50
        (
            [Berlin] => Array //alphabetically from A to Z
                (
                    [1] => Array //from min to max eg. from 0 to 1
                        (
                        )
                 )
         )
)

How can I achieve this in PHP? I hope I was clear enough, feel free to ask in the comments for the additional info.

  • 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-15T08:38:01+00:00Added an answer on June 15, 2026 at 8:38 am

    Would be something like this:

    // ksort sorts the keys low to high
    
    ksort($array[2]);
    
    // uksort w/ natsort is a full alphanumeric sorting A-Z0-9
    uksort($array[2]['Berlin'], 'natsort');
    
    ksort($array[2]['Berlin'][1]);
    

    Documentation on Array and Array Functions:

    https://www.php.net/manual/en/book.array.php

    Functional Example

    This example is real specific to your example; however, you could make a recursive style function if your array structure is really dynamic.

    $BigArray = array();
    
    //Sorting the initial array index
    ksort($BigArray);
    
    foreach($BigArray as $a)
    {
        // Sorting Berlin / Moscow here..
        uksort($a, 'natsort');
        foreach($a as $b)
        {
            // Sorting the index inside the cities
            ksort($b);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a really big array of numbers with double precision...i tried to write
I have a quite complex, even though not really big, array, with many levels
I really have big problems with importing an extern C-Library to my existing C++-Project.
I have been a really big fan of stackoverflow(which led me to ask the
I have a website that just takes a really big form and saves the
I have this method and it's kind of really big so I can't include
I have a really big form with >1000 Elements. They are already nested inside
I have an array which has BIG numbers and small numbers in it. I
I have a class that is mostly a wrapper for a big array and
I have a very simple problem that is giving me a really big headache

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.