I have following JSON data stored in a json file, and architecture of this JSON is different, so this question is not duplicate: -
Why "NULL" is generated from following PHP? : -
<?php
$url = "file.json";
echo $url . "<br>";
$json_string = file_get_contents($url);
echo $json_string . "<br>";
$json_array = json_decode($json_string, true); // need an associative array
var_dump(json_decode($json_array));
?>
Question: if "code": "XXX" exists, how to find values of "city", "state" and "region" in PHP: -
[
{
"code": "XXX",
"city": "Indore",
"state": "Madhya Pradesh",
"region": "W"
},
{
"code": "XXY",
"city": "Vapi",
"state": "Gujarat",
"region": "W"
},
{
"code": "XXZ",
"city": "Kolkata",
"state": "West Bengal",
"region": "E"
},
{
"code": "XXV",
"city": "Sundar Nagar",
"state": "Himachal Pradesh",
"region": "N"
}
]