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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:48:49+00:00 2026-05-31T23:48:49+00:00

I have two arrays, and I am using array_diff_assoc() to get the difference, but

  • 0

I have two arrays, and I am using array_diff_assoc() to get the difference, but it always returns the common set row in the result

It should be returning the new q sets row. What’s wrong with my approach?

Sample data:

$array1 = [
    [12 => 'new q sets'],
    [11 => 'common set']
]

$array2 => [
    [11 => 'common set']
];

After calling array_diff_assoc($array1, $array2), my output is:

[
    [11 => 'common set']
]
  • 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-31T23:48:49+00:00Added an answer on May 31, 2026 at 11:48 pm

    Two values from key => value pairs are considered equal only if (string) $elem1 === (string) $elem2 . In other words a strict check takes place so the string representations must be the same.

    http://php.net/manual/en/function.array-diff-assoc.php

    The (string) value of any array is "Array". Thus, your call to array_diff_assoc is effectively comparing these two things:

    Array ( [0] => "Array" [1] => "Array" ) 
    Array ( [0] => "Array" ) 
    

    Since the thing that is different between those two is the [1] key/value pair from the first array, you get that back ([1] => Array( [11] => common set )).

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

Sidebar

Related Questions

I have two arrays, where I can get from using $result[0] or $result[1]. I've
Using Javascript, I have two arrays called array1 and array2. I set currentArrray to
I have two byte arrays in C# using .NET 3.0. What is the most
I have two arrays. I'd like to merge them into one, but remove the
I have been trying to compare two arrays. Using array_intersect presents no problems. When
I have combined two arrays using array_merge, and now need to sort them alphabetically.
I'm using php with smarty. In php I have two arrays: $code = Array
So, I'm using Jquery and have two arrays both with multiple values and I
I am currently using markercluster plugin with jquery ui maps. I have two arrays
I'm using .NET 3.5. I have two string arrays, which may share one or

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.