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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:09:24+00:00 2026-06-06T13:09:24+00:00

2 different JSON arrays with same keys like below: Array 1: { fruit1 :

  • 0

2 different JSON arrays with same keys like below:

Array 1:

{ "fruit1" : "Apple", "fruit2" : "Banana", "fruit3" : "Grapes" }

Array 2:

{ "fruit1" : "First Fruit", "fruit2" : "Second Fruit", "fruit3" : "Third Fruit" }

As you can see, 2 arrays that have same keys but different values, now what i wanted is that i wanted the result or the display to be like this:

First Fruit is Apple
Second Fruit is Banana
Third Fruit is Grapes

Thanks!

  • 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-06T13:09:25+00:00Added an answer on June 6, 2026 at 1:09 pm
    $str1 = '{ "fruit1" : "Apple", "fruit2" : "Banana", "fruit3" : "Grapes" }';
    $str2 = '{ "fruit1" : "First Fruit", "fruit2" : "Second Fruit", "fruit3" : "Third Fruit" }';
    
    $array1 = json_decode($str1);
    $array2 = json_decode($str2);
    
    foreach ($array1 as $key => $value) {
        if (isset($array2[$key]) {
            echo $value . " is " . $array2[$key];
        } else {
            echo $value . " has no match in array2.";
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For the same host name, I want to do mapping like the following /subdirectory/_different_end_points_.json
My goal is to generate an array having multiple jsons in which different keys
I just ran into something weird. I have two JSON arrays which holds different
In one of my project i want to parse a JSON array with different
One can accomplish same thing using different tools. So have I in examples below.
I am consuming some JSON from two different sources, I end up with two
I want to return the Model (data) of a controller in different formats (JavaScript/XML/JSON/HTML)
What's the best way to output different types of responses f.ex xml, json, html,
According to MDN documentation for JSON.stringify : Properties of non-array objects are not guaranteed
I have an ajax call in jquery which returns 4 different arrays. 3 of

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.