I am from .Net background and I AM NOT ASKING FOR ANY CODE I just need a suggestion so that i can pull my child nodes. This is my JSON
{
"State of Origin 2014":{
"1471137":{
"EventID":1471137,
"ParentEventID":1471074,
"MainEvent":"State Of Origin Series 2014",
"OutcomeDateTime":"2014-06-18 20:10:00.0000000",
"Competition":"State of Origin 2014",
"Competitors":{
"ActiveCompetitors":3,
"Competitors":[
{
"Team":"New South Wales (2 - 1)",
"Win":"2.15"
},
{
"Team":"New South Wales (3 - 0)",
"Win":"3.05"
},
{
"Team":"Queensland (2 - 1)",
"Win":"3.30"
}
],
"TotalCompetitors":3,
"HasWinOdds":true
},
"EventStatus":"Open",
"IsSuspended":false,
"AllowBets":true
},
"1471074":{
"EventID":1471074,
"ParentEventID":0,
"MainEvent":"State Of Origin Series 2014",
"OutcomeDateTime":"2014-07-09 20:10:00.0000000",
"Competition":"State of Origin 2014",
"Competitors":{
"ActiveCompetitors":2,
"Competitors":[
{
"Team":"New South Wales",
"Win":"1.33"
},
{
"Team":"Queensland",
"Win":"3.30"
}
],
"TotalCompetitors":2,
"HasWinOdds":true
},
"EventStatus":"Open",
"IsSuspended":false,
"AllowBets":true
}
},
"State of Origin 2014 Game 2":{
"3608662":{
"EventID":3608662,
"ParentEventID":3269132,
"MainEvent":"New South Wales v Queensland",
"Competitors":{
"ActiveCompetitors":39,
"Competitors":[
{
"TeamName":"New South Wales 6-10",
"Win":"4.70"
},
{
"TeamName":"Queensland 91+",
"Win":"201.00"
}
],
"TotalCompetitors":39,
"HasWinOdds":true
},
"EventStatus":"Open",
"IsSuspended":false,
"AllowBets":true
}
}
}
This is what i have done. I am able to get root element and now i want to go two levels down to grap EventID and OutcomeDateTime.
PHP code
$json_a=json_decode($string,true);
foreach ($json_a as $root_element => $childnode) {
echo($childnode['EventID']);
echo($childnode['OutcomeDateTime']);
echo "<br>";
}
If anyone can just give me a way to get two levels down so that i can work on my other scripts. I had posted this question before but i was not welcomed with good responses may be i was not able to express my question in a better way and many thought i am asking for full source code. This time i just need a method to grap child elements. THanks