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

The Archive Base Latest Questions

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

I am trying to compare two different arrays. I am looking for the values

  • 0

I am trying to compare two different arrays. I am looking for the values that appear in array1 but do not appear in array2. I have been banging my head against the wall about this because it seems so simple but does not work.

I have tried to find the keys of the array and then i was going to search for them

$orgKey;
      foreach($org as $k => $v){
          $orgKey[$k][] = $v['title'];
      }
      $newKey;
      foreach($new as $k => $v){
          $newKey[$k][] = $v['title'];

      }
      echo "orgkey";
      echo print_r($orgKey);
      echo "newkey<br/>";
      echo print_r($newKey);   
      $e = array_diff($orgKey,$newKey);
      echo print_r($e);

but this gives me an empty array everytime.

I have also tried foreach within foreach and realized i cannot find out how to search through a value that is not there without it duplicating because of the foreach loop itself.

foreach($org as $k => $v){
          foreach($new as $a => $b){  
              $count = count($new);
              $i = 0;
              if($v['title'] == $b['title']){
       //This is where i realize i will find duplicates of values that don't exist

              }

          }
      }

My arrays. $org

[0] => Array
        (
            [title] => Ahiris Angels
            [r_id] => 1276
            [t_id] => 1277
            [name] => 
            [column1] => 
            [column2] => 
        )

    [1] => Array
        (
            [title] => Alistars Stars
            [r_id] => 1276
            [t_id] => 1278
            [name] => 
            [column1] => 
            [column2] => 
        )

    [2] => Array
        (
            [title] => Ammumu
            [r_id] => 1276
            [t_id] => 1279
            [name] => 
            [column1] => 
            [column2] => 
        )

The $new array can be any values but keeps the structure of the $org array.

My Goal is to have an array like this $org

 [0] => Array
            (
                [title] => Ahiris Angels
                [r_id] => 1276
                [t_id] => 1277
                [name] => 
                [column1] => 
                [column2] => 
            )

        [1] => Array
            (
                [title] => Alistars Stars
                [r_id] => 1276
                [t_id] => 1278
                [name] => 
                [column1] => 
                [column2] => 
            )

Compare it to $new

[0] => Array
                (
                    [title] => Ahiris Angels
                    [r_id] => 1276
                    [t_id] => 1277
                    [name] => 
                    [column1] => 
                    [column2] => 
                )

And my Result will be

[1] => Array
                (
                    [title] => Alistars Stars
                    [r_id] => 1276
                    [t_id] => 1278
                    [name] => 
                    [column1] => 
                    [column2] => 
                )
  • 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-30T23:54:50+00:00Added an answer on May 30, 2026 at 11:54 pm

    This should do what you’re trying to do:

    foreach ($org as $v)
    {
        $orgKey[$v['title']] = $v;
    }
    foreach ($new as $v)
    {
        $newKey[$v['title']] = $v;
    }
    $e = array_diff_key($orgKey, $newKey);
    $e = array_values($e);
    

    The last call to array_values is optional; it just reassigns sequential integers to the keys rather than leaving in the titles.

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

Sidebar

Related Questions

I am trying to compare two arrays that always have different dimensions. eg. arr1
I have been trying to compare two arrays. Using array_intersect presents no problems. When
I am trying to compare two decimal values in Java script. I have two
C# I'm trying to compare two different objects (I'm only comparing identical subfields). But
I'm trying to make a function that compares two different length arrays to each
Im trying to compare two different string encoded by sha512. But, result is different.
I'm trying to compare two arrays in groovy. My attempts so far have yielded
I am trying to compare two strings in Smalltalk, but I seem to be
I am trying to compare two dates. I have this code which I thought
I'm trying to compare two datetimes but I can't get it to work. public

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.