Good day. First time working with .json. It used to manage the database, but now he needs it. Question 2 and are as follows: 1. How to connect the local data.json file to the actual code. 2. How to access the nested arrays (and so it tried, it does not work)
<style> *{ font-size: 60px; } </style> <? $cityFrom = $_GET['cityFrom']; $cityTo = $_GET['cityTo']; trim($cityFrom); trim($cityTo); $errorState = 0; //All is good; if($cityFrom == $cityTo) { $errorState = 1; //Same citeis; echo "<script language = \"javascript\"> alert(\"Entered same cities / Введены одинаковые города\"); window.location.href = \"order.html\"; </script>"; } if($cityFrom != "Kazan" && $cityTo != "Kazan") { $errorState = 2; //Not exist way; } ?> <script language = "javascript" > //Вызов json из "data.json" </script> Json file is filled for 1 city and looks like this: (How can I remove city.Kazan.Ufa [0] from there; something like that)
{ "city": [ { "Kazan": [ { "Ufa": ["8:00", "10:00", "11:00", "13:00", "16:00", "21:00", "22:00", "23:00"], "Izhevsk": [], "Chelny": [], "Elabuga": [], "Nizhnekamsk": [], "Almet": [], "Ulyanovsk": [], "Samara": [], "Tolyati": [], "Moscow": [], "SP": [], "Yoshkarola": [], "Kirov": [], "Novgorod": [] } ], "Ufa" : [ { "Kazan": ["6:00", "8:00", "10:00", "14:00", "18:00", "21:00", "22:00", "00:00"] } ], "Izhevsk": [ { "Kazan": [] } ], "Chelny": [ { "Kazan": [] } ], "Elabuga": [ { "Kazan": [] } ], "Nizhnekamsk": [ { "Kazan": [] } ], "Almet": [ { "Kazan": [] } ], "Ulyanovsk": [ { "Kazan": [] } ], "Samara": [ { "Kazan": [] } ], "Tolyati": [ { "Kazan": [] } ], "Moscow": [ { "Kazan": [] } ], "SP": [ { "Kazan": [] } ], "Yoshkorola": [ { "Kazan": [] } ], "Kirov": [ { "Kazan": [] } ], "Novgorod": [ { "Kazan": [] } ] } ] }