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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:12:07+00:00 2026-05-23T01:12:07+00:00

I need some help with sorting a multidimensional array in php. I need the

  • 0

I need some help with sorting a multidimensional array in php. I need the array to be grouped into months, and then sorted by month. Here’s my original array:

Array
(
    [0] => Array
        (
            [IdEvent] => 5
            [EventName] => Copy of Opening snow weekend
            [Year] => 2011
            [Month] => 08
        )

    [1] => Array
        (
            [IdEvent] => 7
            [EventName] => Copy of Copy of Opening snow weekend
            [Year] => 2011
            [Month] => 07
        )

    [2] => Array
        (
            [IdEvent] => 1
            [EventName] => Opening snow weekend
            [Year] => 2011
            [Month] => 05
        )

    [3] => Array
        (
            [IdEvent] => 6
            [EventName] => Copy of Opening snow weekend
            [Year] => 2011
            [Month] => 05
        )

)

And here’s what I’m hoping to get:

Array
(

    [0] => Array (

        [0] => Array
            (
                [IdEvent] => 1
                [EventName] => Opening snow weekend
                [Year] => 2011
                [Month] => 05
            )

        [1] => Array
            (
                [IdEvent] => 6
                [EventName] => Copy of Opening snow weekend
                [Year] => 2011
                [Month] => 05
            )

    )

    [1] => Array (

        [0] => Array
            (
                [IdEvent] => 7
                [EventName] => Copy of Copy of Opening snow weekend
                [Year] => 2011
                [Month] => 07
            )

    )

    [2] => Array (

        [0] => Array
            (
                [IdEvent] => 5
                [EventName] => Copy of Opening snow weekend
                [Year] => 2011
                [Month] => 08
            )
    )

)
  • 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-23T01:12:08+00:00Added an answer on May 23, 2026 at 1:12 am

    I would use an easily sortable key for each month-container, then just use ksort

    $months = array();
    foreach ($input_array AS $arr) {
      $months[$arr['Month']][] = $arr;
    }
    ksort($months);
    

    if you want, you can then use array_values to turn it into a standard integer-key array

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

Sidebar

Related Questions

I made this function and need some help sorting out the logic flow. It
Need some help. This javascript code should set the target of the form and
Need some help refactoring this if/else block that builds the conditions for a find
Need some help with putting this query together. I'm using Mysql I have two
Need some help refactoring this code: $(span[rel=color_content]).ColorPicker({ onChange: function (hsb, hex, rg) { $(span[rel=color_content]).css('background-color',
need some help from a regex jedi master: If I have a string of
I need some help with finding network interfaces based on a provided IP address.
I've got some help turning my table of the sort: Col 23 25 15
I have a list with values from the db, and with jquery ui I
Im tryingh to create a list view but im having issues designing it how

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.