Skip to content
Advertisement

how to search inside two JSON files at a time in PHP

I have two JSON files of same format, forexample

1st JSON File

JavaScript

2nd JSON file

JavaScript

Each user has a unique “id”, I want to get their id by searching their name in php, how can I do this

This is my PHP script

JavaScript

Each user has a unique “id”, I want to get their id by searching their name in php. How can I get id by searching name in both files at a time?

Thanks

Advertisement

Answer

Since you are looping through json file it will search inside of “data” so you can’t use $v['data']

Also since edges is also array that have same values and you want to search inside of it you must make loop on that also

Here is example

JavaScript

Output

JavaScript

EDIT

Since you want to search in both files at a same time you can put them into array and then use it like this

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement