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

  • Home
  • SEARCH
  • 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 3848170
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:39:44+00:00 2026-05-19T16:39:44+00:00

I really need some help to figure this one out. I’ve got a number

  • 0

I really need some help to figure this one out.

I’ve got a number of arrays and i would like to merge some of them. It looks like as following.

            while ($row = $db->fetch_array($result_set)) {
                $year           = $row['year(Tidspunkt)'];
                $month_num      = $row['month(Tidspunkt)'];
                $month      = $cal->name_of_month($row['month(Tidspunkt)']);
                $type           = $row['Klubtype'];
                $visits         = $row['count(Handling)'];
                $days_in_month = $cal->days_in_month($month_num,$year);
                $avg           = $visits / $days_in_month;
                $object_array[]= array('month' => $month , 'visits' => $visits, 'type' => $type, 'avg' => $avg);
            }
            return $month_array;

And the output looks like this

Array ( 
     [0] => Array ( [month] => Januar [visits] => 891 [type] => FK [avg] => 28.7419354839 ) 
     [1] => Array ( [month] => Januar [visits] => 23 [type] => UK [avg] => 0.741935483871 ) 
)

Now I would like to merge these two arrays based on the value of month. Imagine when I’ve got arrays for a whole year. Then it would be nice to have 12 arrays instead of 24.

Thanks for helping me out.

  • 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-19T16:39:45+00:00Added an answer on May 19, 2026 at 4:39 pm

    I think this may be what you want…

    $newArray = array();
    
    foreach($array as $value) {
    
       $month = $value['month'];
       unset($value['month']);
       $newArray[$month][] = $value;
    }
    

    This will give you something like…

    Array ( 
         ['Januar'] => Array (
            [0] => Array( [visits] => 891 [type] => FK [avg] => 28.7419354839 ) 
            [1] => Array ( [visits] => 23 [type] => UK [avg] => 0.741935483871 ) 
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had some help today with a need and this is what I have
I need some help optimizing a section of math heavy code. I've done the
I need some help for an assignment, I asked a question related to it
I have a string that looks like this: (12.0+10)*31 I need to be able
I am somewhat confused, need some C/C++ guru here. If it is C and
I feel like a 4-year old who has a slice of bread with pb
We have an Asp.NET application holding all of our server logic. This application only
So I am really stumped because I have basic ideas but I am looking
I've been trying and trying to make my generic extension methods work, but they
I am writing a python script in order to write a tex file. But

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.