I have a JSON file in this format:
[
["name","purpose","description"],
["name2","purpose2","description2"],
["name3","purpose3","description3"]
]
Now, I have got the solutions for finding them by key. But, my JSON doesn't have keys. How can I search inside this JSON object to find second element by using "purpose2"? Also, I need to display the second element (i.e. "name2","purpose2","description2").
I used this function, but it's not helping me out.
function searchJson($obj, $value) {
foreach($obj as $item) {
foreach($item as $child) {
if(isset($child) && $child == $value) {
return $child;
}
}
}
return null;
}
Thanks in advance !