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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:41:21+00:00 2026-06-11T16:41:21+00:00

How do I create a new multidimensional array by merging two arrays and removing

  • 0

How do I create a new multidimensional array by merging two arrays and removing any duplicate rows.

First array:

[
    0 => ["id" => "0001", "name" => "sample name 1"],
    1 => ["id" => "0002", "name" => "sample name 2"],
    3 => ["id" => "0003", "name" => "sample name 3"]
]

Second Array:

[
    0 => ["id" => "0002", "name" => "sample name 2"],
    1 => ["id" => "11323", "name" => "blah blah"]
]

The desired result is:

[
    ["id" => "0001", "name" => "sample name 1"],
    ["id" => "0002", "name" => "sample name 2"],
    ["id" => "0003", "name" => "sample name 3"]
    ["id" => "11323", "name" => "blah blah"]
]
  • 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-11T16:41:22+00:00Added an answer on June 11, 2026 at 4:41 pm

    You can do this

    $array1 = Array(
            0 => Array("id" => "0001","name" => "sample name 1"),
            1 => Array("id" => "0002","name" => "sample name 2"),
            3 => Array("id" => "0003","name" => "sample name 3"));
    
    $array2 = Array(
            0 => Array("id" => "0002","name" => "sample name 2"),
            1 => Array("id" => "11323","name" => "blah blah"));
    
    $output = array_map("unserialize", array_unique(array_map("serialize", array_merge($array1,$array2))));
    
    var_dump($output);
    

    Output

    array
      0 => 
        array
          'id' => string '0001' (length=4)
          'name' => string 'sample name 1' (length=13)
      1 => 
        array
          'id' => string '0002' (length=4)
          'name' => string 'sample name 2' (length=13)
      2 => 
        array
          'id' => string '0003' (length=4)
          'name' => string 'sample name 3' (length=13)
      4 => 
        array
          'id' => string '11323' (length=5)
          'name' => string 'blah blah' (length=9)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multidimensional array and I want to create new variables for each
I have a multidimensional array and I want to create new variables based on
Code to create new form instance of a closed form using form name I
I am beginner level in android. how to create multidimensional array in android at
Im looking for an example of multidimensional arrays. I have an array of thumbtails
I have two multidimensional arrays like: [a] [b] [c] and [a] [b] [c] [d]
In C# there are 2 ways to create mutlidimensional arrays. int[,] array1 = new
Assuming the following example array: {/documents, /documents/files, /pictures} I wish to create a multidimensional
I need to create global two dimensional array in jquery or javascript My function
I create new desktop with CreateDesktop and want to get it's DC & RC.

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.