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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:02:36+00:00 2026-06-17T03:02:36+00:00

I need some help about sorting a multiple array. This is what I got:

  • 0

I need some help about sorting a multiple array.
This is what I got:

Array ( 
   [ALU0000001] => 
         Array ( [0] => Array ( [period] => 2012 [codCurse] => S12-2030 [idPersona] => ALU0000001 [date] => 2012-04-02 [amount] => 238.00 [active] => X ) 
                 [1] => Array ( [period] => 2012 [codCurse] => S12-2030 [idPersona] => ALU0000001 [date] => 2012-05-02 [amount] => 238.00 [active] => X )
                 [2] => Array ( [period] => 2012 [codCurso] => S12-2030 [idPersona] => ALU0000001 [date] => 2012-06-02 [amount] => 238.00 [active] => X )
                 [3] => Array ( [period] => 2013 [codCurso] => S12-2030 [idPersona] => ALU0000001 [date] => 2013-01-02 [amount] => 238.00 [active] => X )

   [ALU0000005] =>
         Array ( [0] => Array ( [period] => 2013 [codCurse] => S13-2010 [idPersona] => ALU0000005 [date] => 2013-03-01 [amount] => 225.00 [active] => X )
                 [1] => Array ( [period] => 2013 [codCurse] => S13-2010 [idPersona] => ALU0000005 [date] => 2013-03-02 [amount] => 333.00 [active] => X ) 
                 [2] => Array ( [period] => 2013 [codCurse] => S13-2010 [idPersona] => ALU0000005 [date] => 2013-04-02 [amount] => 333.00 [active] => X ) 

I need to sort multiarray by period date to get something like this

  Y   M   D
  2012 2012-04-02 ALU00000001 .....
  2012 2012-05-02 ALU00000005 .....
  2012 2012-06-01 ALU00000001 .....
  2013 2013-01-01 ALU00000001 .....
  2013 2013-06-01 ALU00000001 .....
  2013 2013-12-24 ALU00000005 .....

Thanks

  • 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-17T03:02:37+00:00Added an answer on June 17, 2026 at 3:02 am

    Considering the main array keys don’t do much (because they’re already contained within the values by the date key) you can safely ignore them. So first you want to collect all the values into a single array to be able to sort later:

    $allItems = array();
    foreach ($outputArr as $arr) { // $outputArr should be the name of your array
        $allItems = array_merge($allItems,array_values($arr));
    }
    

    Then you need to sort the array values by the date keys:

    function sortByDate($a,$b) {
        $d1 = strtotime($a['date']);
        $d2 = strtotime($b['date']);
        return $d1 == $d2 ? 0 : ($d1 > $d2 ? 1 : -1);
    }
    usort($allItems,'sortByDate');
    // and there you go.
    print_r($allItems);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help on this problem. It is about ASP.NET MVC3. I have
I need some help about mod_rewrite, this is my wordpress address: http://localhost/my_v2010/restaurants?m=display_Add base_url: http://localhost/my_v2010/
I need some help about converting JSON object that contains multidimensional array to my
I need some help about optimisation. I am trying to improve this open-source game
Need some help about this one. I have a Telerik:RadGridView control and define the
Need some help with this code I got off the net $(document).ready(function(){ jQuery(.linkbar li).each(function(){
I need some help about WCF and authorization. Currently I have a client which
I need some help about RegExp in AS3. I have a simple pattern :
I need some help with PHP Class. I have limited knowledge about how it
Need some help to solve this. I have a gridview and inside the gridview

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.