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

  • SEARCH
  • Home
  • 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 8613915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:59:40+00:00 2026-06-12T04:59:40+00:00

I am new to php and still learning the language, let say I have

  • 0

I am new to php and still learning the language,

let say I have two array

For Example

Array
(
    [house_id] => 6
    [name] => Lake Villa
    [floor] => 5
    [unit] => 25
)

Array
(
    [house_id] => 6
    [name] => Lake Villa
    [floor] => 5
    [unit] => 25
    [parking_id] => 9
    [resident_count] => 4
)

How do i get the keys of 1st array onto second, what i am saying is, i just need house_id, name, floor, unit from second array and discard rest of the information.

However, they key is not same and dynamic, which means the first array key whatever returned is also present on second but with additional information. The information above is just an example and the keys might varies but whatever key on first array contains on second array too.

I tried this, but isn’t working:

foreach($arr1 as $k=>$v) {
    foreach($arr2 as $j=>$w) {
        if(isset($arr2[$k]))
            $arr[$k] = $w;
    }
}
  • 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-12T04:59:41+00:00Added an answer on June 12, 2026 at 4:59 am

    You could use array_intersect_key, to merge the arrays.

    $newArray = array_intersect_key($array2, $array1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to PHP (still) and keep learning. I often have to retrieve
So, I'm still new with the php coding, still learning, etc. So, if this
I'm quite new to PHP so I'm still learning the very basics, however I'm
So I am still somewhat new to PHP, MySQL, and Javascript but I have
I'm still quite new to OOP, and have been learning-as-I-go with CodeIgniter2+Doctrine2. I have
I am still pretty new to PHP so forgive me if I am overlooking
New to PHP and MySQL, have heard amazing things about this website from Leo
Am new to php... I have been battling on my dynamic checkboxes in such
I have the following code: <?php require_once('IPTC.php'); $iptc = new Image_IPTC('001.jpg'); print_r($iptc); ?> And
I'm still fairly new to PHP and so I'm attempting to understand scope concepts

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.