How to get common value from two json file (array) in php ?

in hive-185836 •  3 years ago 

This is one way to check the difference between two array or json. Make sure the pattern in json / array is similar to one another or else you will see error.

    $json1 = file_get_contents('https://yourendpointurlhere.com/json1');
    //This is response returned from an endpoint.

carbon.png

    $json2 = file_get_contents('https://yourendpointurlhere.com/json2');
    //This is response returned from an endpoint.

carbon (1).png

Here we want to get common name from two file. As array counting starts from 0, the name indexing is 1.

Here is the sample code for the implementation.

carbon (2).png

You will get array of names in result. Hope that helps

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
Loading...