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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:58:39+00:00 2026-05-23T22:58:39+00:00

Having the following two different arrays in php: Array1 ( [0] => Array (

  • 0

Having the following two different arrays in php:

Array1
(
    [0] => Array
        (
            [id] => 1
            [name] => William
        )

    [1] => Array
        (
            [id] => 2
            [name] => Bob
        )

    [2] => Array
        (
            [id] => 3
            [name] => Michael
        )

)
Array2
(
    [0] => Array
        (
            [id] => 11128
            [name] => John
        )

    [1] => Array
        (
            [id] => 11127
            [name] => Adam
        )

    [2] => Array
        (
            [id] => 11126
            [name] => Andrew
        )

    [3] => Array
        (
            [id] => 11125
            [name] => William
        )

    [4] => Array
        (
            [id] => 11124
            [name] => Bob
        )

)

Can I somehow find matching names so the output will be like:

Array1 (1, id:2) matches Array2 (4, id:11124) with name: Bob
Array1 (0, id:1) matches Array2 (3, id:11125) with name: William

sorry if it’s unclear

  • 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-23T22:58:40+00:00Added an answer on May 23, 2026 at 10:58 pm

    You can always try a simple foreach loop:

    <?php
    foreach($array1 as $key1=>$value1) {
        foreach($array2 as $key2=>$value2) {
            if($value1['name'] === $value2['name']) {
                sprintf('Array1 (%d, id:%d) matches Array2 (%d, id:%d) with name: %s', $key1, $value1['id'], $key2, $value2['id'], $value1['name']);
            }
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having the following classes, in two different assemblies: class Member { public string Label
I have following HTML with two elements having the same name <input type=hidden name=
Having loaded two different images I want to do the following operation and obtain
I'm having the following two tables... Table : room_type type_id type_name no_of_rooms max_guests rate
I'm having the following problem: When I got two labels into each other: <Label
I'm having an issue with accessing objects within two different instances of the SPSite
I am following some examples in the book, and I noticed two different conventions
I am having trouble compiling a program I have written. I have two different
I am having trouble constructing a single XPath statement to return two different sets
Which are the diferrences between the following two queries? Both returns different rows: with

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.