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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:30:27+00:00 2026-05-27T18:30:27+00:00

I have an array in the format of Array ( [0] => Array (

  • 0

I have an array in the format of

Array
(
    [0] => Array
        (
            [platform] => 1
            [sales] => 244
            [total] => 245971.00
            [average] => 1008.08
        )

    [1] => Array
        (
            [platform] => 2
            [sales] => 273
            [total] => 280454.48
            [average] => 1027.31
        )

    [2] => Array
        (
            [platform] => 3
            [sales] => 290
            [total] => 273408.00
            [average] => 942.79
        )

)

and another array

Array
(
    [0] => Array
        (
            [platform] => 1
            [sales] => 243
            [total] => 245231.00
            [average] => 1128.08
        )

    [1] => Array
        (
            [platform] => 2
            [sales] => 233
            [total] => 2804248
            [average] => 103.31
        )

    [2] => Array
        (
            [platform] => 3
            [sales] => 293
            [total] => 223408.00
            [average] => 942.29
        )

)

How could I add these arrays together to create an array of all the values added.

For example, [sales] => 244 from the first array containing platform 11 and [sales] => 243 in the seconds array containing platform 1. I want to combine them into an array where [sales] => 487 (244 + 243) for platform 1.

Thanks in advance

  • 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-27T18:30:28+00:00Added an answer on May 27, 2026 at 6:30 pm

    Assuming the two arrays have an exact 1:1 match between their respective keys:

    $new_arr = array();
    foreach($arr1 as $main_key => $sub_arr) {
        foreach($sub_arr as $sub_key => $val) {
            $new_arr[$main_key][$sub_key] = $val + $arr2[$main_key][$sub_key];
        }
    }
    

    where $arr1 and $arr2 are your two original arrays.

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

Sidebar

Related Questions

I have an array in this format: $array = [ ['id' => 117, 'name'
I have a 128-byte (1024-bit) modulus (in a byte array format) and my exponent
I have an array of bytes representing an image in Windows BMP format and
I have an array of dates which are in the format 20100808 (YYYYMMD). How
All, I have the following array in array format. The JSON format is shown
How to convert a string format into an array format? I have a string,
I have a PHP array of associative arrays with the following format: array(1) {
I have an array in the format Array ( [/Callum/] => Array ( [0]
I have an array in the following format: Array ( [0] => Array (
I have an array of timestamps in the format (HH:MM:SS.mmmmmm) and another array of

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.