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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:41:38+00:00 2026-05-27T13:41:38+00:00

I have three arrays each having SimpleXML Objects in them. They are structured like

  • 0

I have three arrays each having SimpleXML Objects in them. They are structured like so:

Array
(
    [0] => SimpleXMLElement Object
        (
            [post_id] => 1476
            [name] => Johnson Fisheries Ltd.
            [owner] => Mr. John Johnson
        )
)

I want to be able to compare all 3 arrays and filter out the differences so that the results have only the elements that are the same in all 3 arrays.

For example:

Array1
    (
        [0] => 1476
        [1] => 1560
        [2] => 1342
    )

Array2
    (
        [0] => 2454
        [1] => 1476
    )

Array3
    (
        [0] => 3412
        [1] => 7512
        [2] => 2454
        [4] => 1476
    )

The resulting array would only contain [0] => 1476

What’s the best way to do this? I’ve looked for a function that will compare arrays in this way but I have had no luck. Any ideas?

Any help is very appreciated!

  • 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-27T13:41:39+00:00Added an answer on May 27, 2026 at 1:41 pm

    Loop over your first array, checking it against the 2nd and 3rd using in_array, like this:

    foreach($array1 as $post_id) {
        if(in_array($post_id, $array2) && in_array($post_id, $array3)) {
            // We have a winner!
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three arrays, all the same size: xout % cell array xin %
I have a tree that consists of several objects, where each object has a
Im having a weird issue with json arrays. Inside each array, there is another
I have three arrays (it's written in C but that is not important, it
I want to do permutation in Perl. For example I have three arrays: [big,
I have two String arrays a,b. String a [] = {one,two,three}; String b []
I have a three-dimensional array that I want to reset to zero. It seems
I have three colors in an array, array('blue', 'red', 'green') , and in my
I have an array in Perl: my @my_array = (one,two,three,two,three); How do I remove
I have two arrays of values like X,Y,Z and 1,2 There is a table

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.