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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:45:03+00:00 2026-06-01T21:45:03+00:00

I have mutiple arrays say for now 2, first array has Cities(Mumbai, Pune. Bangalore,

  • 0

I have mutiple arrays say for now 2, first array has Cities(Mumbai, Pune. Bangalore, Hyderabad)
And 2nd array has Mumbia nad Hyderabd.

I want to sum up the values based on the Key.

Array
(
[Mumbai] => Array
(
[ga:pageviews] => 1
[ga:visits] => 1
[ga:newVisits] => 1
[ga:pageviewsPerVisit] => 1
[ga:entranceBounceRate] => 1
[ga:avgTimeOnSite] => 1
[ga:timeOnSite] => 1
[ga:bounces] => 1
)

[Pune] => Array
    (
        [ga:pageviews] => 2
        [ga:visits] => 2
        [ga:newVisits] => 2
        [ga:pageviewsPerVisit] => 2
        [ga:entranceBounceRate] => 2
        [ga:avgTimeOnSite] => 2
        [ga:timeOnSite] => 2
        [ga:bounces] => 2
    )

[Bangalore] => Array
    (
        [ga:pageviews] => 3
        [ga:visits] => 3
        [ga:newVisits] => 3
        [ga:pageviewsPerVisit] => 3
        [ga:entranceBounceRate] => 3
        [ga:avgTimeOnSite] => 3
        [ga:timeOnSite] => 3
        [ga:bounces] => 3
    )

[Hyderabad] => Array
    (
        [ga:pageviews] => 4
        [ga:visits] => 4
        [ga:newVisits] => 4
        [ga:pageviewsPerVisit] => 4
        [ga:entranceBounceRate] => 4
        [ga:avgTimeOnSite] => 4
        [ga:timeOnSite] => 4
        [ga:bounces] => 4
    )

)

2nd Array:

Array
(
[Mumbai] => Array
(
[ga:pageviews] => 5
[ga:visits] => 5
[ga:newVisits] => 5
[ga:pageviewsPerVisit] => 5
[ga:entranceBounceRate] => 5
[ga:avgTimeOnSite] => 5
[ga:timeOnSite] => 5
[ga:bounces] => 5
)

[Hyderabad] => Array
    (
        [ga:pageviews] => 2
        [ga:visits] => 2
        [ga:newVisits] => 2
        [ga:pageviewsPerVisit] => 2
        [ga:entranceBounceRate] => 2
        [ga:avgTimeOnSite] => 2
        [ga:timeOnSite] => 2
        [ga:bounces] => 2
    )

)

I want the result as:

Array
(
[Mumbai] => Array
(
[ga:pageviews] => 6
[ga:visits] => 6
[ga:newVisits] => 6
[ga:pageviewsPerVisit] => 6
[ga:entranceBounceRate] => 6
[ga:avgTimeOnSite] => 6
[ga:timeOnSite] => 6
[ga:bounces] => 6
)

[Pune] => Array
    (
        [ga:pageviews] => 2
        [ga:visits] => 2
        [ga:newVisits] => 2
        [ga:pageviewsPerVisit] => 2
        [ga:entranceBounceRate] => 2
        [ga:avgTimeOnSite] => 2
        [ga:timeOnSite] => 2
        [ga:bounces] => 2
    )

[Bangalore] => Array
    (
        [ga:pageviews] => 3
        [ga:visits] => 3
        [ga:newVisits] => 3
        [ga:pageviewsPerVisit] => 3
        [ga:entranceBounceRate] => 3
        [ga:avgTimeOnSite] => 3
        [ga:timeOnSite] => 3
        [ga:bounces] => 3
    )

[Hyderabad] => Array
    (
        [ga:pageviews] => 6
        [ga:visits] => 6
        [ga:newVisits] => 6
        [ga:pageviewsPerVisit] => 6
        [ga:entranceBounceRate] => 6
        [ga:avgTimeOnSite] => 6
        [ga:timeOnSite] => 6
        [ga:bounces] => 6
    )

)

Thanks for your help….
Ruth.

  • 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-01T21:45:04+00:00Added an answer on June 1, 2026 at 9:45 pm
    foreach($arr2["Hyderabad"] as $key => $val)
    {
        $arr1["Hyderabad"][$key] += $val;
    }
    

    That should do it for you 🙂

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

Sidebar

Related Questions

Assume that we have multiple arrays of integers. You can consider each array as
I have a multidimensional array, and I would have multiple arrays within it. Some
I have an html document with multiple commented-out PHP arrays, e.g.: <!-- Array (
I have a dynamically generated array of filenames, let's say it looks something like
(Before anyone asks, it's not homework.) Say you have 2 Arrays y0 and y1
I have a situation where I have two arrays and I use one array(A)
I have a class (say Product) with a property (say product_id) and has methods
I need to merge associative arrays and group by the name. Say I have
Let's say I have an array of floating point numbers, in sorted (let's say
I have a function that adds shopping cart data to an array of arrays.

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.