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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:46:26+00:00 2026-05-16T02:46:26+00:00

I have two arrays that are structured like this $array1 = Array ( [0]

  • 0

I have two arrays that are structured like this

$array1 = Array
 (
     [0] => Array
         (
             ['story_id'] => 47789
         )

     [1] => Array
         (
             ['story_id'] => 47779
         )

     [2] => Array
         (
             ['story_id'] => 47776
         )

     [3] => Array
         (
             ['story_id'] => 47773
         )

     [4] => Array
         (
             ['story_id'] => 47763
         )
 )


$array2 = Array
 (
     [0] => Array
         (
             ['story_id'] => 47789
         )

     [1] => Array
         (
             ['story_id'] => 47777
         )

     [2] => Array
         (
             ['story_id'] => 47776
         )

     [3] => Array
         (
             ['story_id'] => 47773
         )

     [4] => Array
         (
             ['story_id'] => 47763
         )
 )

and I want to get the difference of array1 from array2 so I tried using

    $results = array_diff($array1, $array2);

but it turns up empty is there any easy way around this or would it be best for me to get the arrays boiled down and if so is there easy way to do that ?

  • 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-16T02:46:27+00:00Added an answer on May 16, 2026 at 2:46 am

    It because that the array_diff is only use for 1 dimension array. For your 2 array, let use some code from php.net

    function multidimensional_array_diff($a1, $a2)
    {
    $r = array();
    
    foreach ($a2 as $key => $second) {
        foreach ($a1 as $key => $first) {
    
            if (isset($a2[$key])) {
                foreach ($first as $first_value) {
                    foreach ($second as $second_value) {
                        if ($first_value == $second_value) {
                            $true = true;
                            break;
                        }
                    }
                    if (!isset($true)) {
    
                        $r[$key][] = $first_value;
                    }
                    unset($true);
                }
            } else {
                $r[$key] = $first;
            }
        }
    }
    return $r;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 537k
  • Answers 537k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer SELECT * FROM DNA_entrys WHERE month(`SubmissionDate`) = 2 AND year(`SubmissionDate`)… May 17, 2026 at 1:49 am
  • Editorial Team
    Editorial Team added an answer You can force the value to be returned as a… May 17, 2026 at 1:49 am
  • Editorial Team
    Editorial Team added an answer strtok() is a standard function for parsing strings with arbitrary… May 17, 2026 at 1:49 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a tree-like object structure that consists of two types of objects: object
I'm trying to build an array structured like [ [num, [num, num num]], [num,
I have two arrays of chars, allocated as follows: unsigned char *arr1 = (unsigned
I need to have a list(array, ect) of objects that have a static values.
I have some C code that I have to port to C++. The code
I have created a VB.NET 2008 Class Library that has, for the most part,
I am attempting to write a simple particle system that leverages CUDA to do
Great site! I have a question I haven't seen answered. I am very new
Using C++ and the STL, does anybody know how to store integer arrays as
I have the following structure: MyClass { guid ID guid ParentID string Name }

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.