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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:24:33+00:00 2026-06-01T21:24:33+00:00

My problem is: I have an array called $ownerArray that another array need to

  • 0

My problem is:

I have an array called $ownerArray that another array need to check against and if a key exists in both arrays display the value of the matching key. $ownerArray is populated by a database so i can’t just write an ir statement within a if statement.

$ownerArray will look like this:

$ownerArray = array(0 =>'Name0',1 =>'Name1',2 =>'Name2',3 =>'Name3');

Then I have another array called $Users that has a various number of values depending on what the user selects, so $Users could look like this:

$Users = '1,2'

or Like this:

$Users = '1,3'

$Users is never the same.

But I need the $value of $ownerArray to display if any of the values integers of $Users match any $key of $ownerArray

Example:

foreach($ownerArray as $key => $value) 
            { 
                if(in_array($key,array($Users)))
                {
                    print $value; 
                } 
            }

This method stops at the fist match and displays the correct name. The loop doesn’t continue printing if more values match.

What im looking for is if $Users = ‘1,3’ my for loop will print Name1 and Name3 from the $ownerArray.

Thanks for the help!

ps i know i could use if($key==1 || $key ==2) but that will not work for this case.

  • 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-01T21:24:34+00:00Added an answer on June 1, 2026 at 9:24 pm
    $merged = array_flip(array_intersect(array_flip($owners), explode(',', $users)));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pretty simple problem. Basically I have an array called $list that
I have problem i need to convert from my Array structure to std::vector<int> ...
I have a problem with some numpy stuff. I need a numpy array to
I have an array called $users (below), that i would like to print first_name
I have a problem that should be quite common. I have an Array of
A toy-case for my problem: I have a numpy array of size, say, 1000:
I have a little problem, I have an array and I want to add
My problem is as follows. I have an array of objects in the form
I'm having a trouble with this little problem. Let's say, I have an array,
I have a problem initializing an array whose size is defined as extern const.

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.