JSON complex tree with PHP
<p>I don't know how to do to extract the following JSON objects. I try to use foreach but it's not working. Could you help me?
Here the JSON file :</p>

<pre><code>{
    "success":true,
    "moreDataAvailable":true,
    "ewons":
        [
            {
                "id":252459,
                "name":
                "eWON_TEST",
                "tags":
                    [

                        {
                            "id":107060,
                            "name":"TEMP_EXT",
                            "dataType":"Int",
                            "description":"Température extérieure",
                            "alarmHint":"",
                            "value":15.0,
                            "quality":"good",
                            "ewonTagId":1,
                            "history":
                                [
                                    {
                                    "date":"2016-05-09T16:06:49Z",
                                    "quality":"initialGood",
                                    "value":64.0
                                    },

                                    {
                                    "date":"2016-05-09T16:16:49Z",
                                    "quality":"initialGood",
                                    "value":6.0
                                    },

                                    {
                                    "date":"2016-05-09T16:21:49Z",
                                    "quality":"initialGood",
                                    "value":6.0
                                    }
                                ]
                        },

                        {
                            "id":107072,
                            "name":"TEMP_IN",
                            "dataType":"Int",
                            "description":"Température intérieure",
                            "alarmHint":"",
                            "value":22.0,
                            "quality":"good",
                            "ewonTagId":5,
                            "history":
                                [
                                    {
                                    "date":"2016-05-09T17:01:49Z",
                                    "quality":"initialGood",
                                    "value":22.0
                                    },

                                    {
                                    "date":"2016-05-09T17:06:49Z",
                                    "value":22.0
                                    },

                                    {
                                    "date":"2016-05-09T17:11:49Z",
                                    "value":22.0
                                    }
                                ]

                        }
                    ],
                "lastSynchroDate":"2016-12-16T15:21:22Z"
            }
        ]
}
</code></pre>

<p>In fact, I would like to display the history for each tags with the following information on each line :</p>

<pre><code>['id'],['name'],['dataType'],['descritption'],['ewonTagId'],['id(from ewons)'],['name(from ewons)'],['date'],['quality(from history)'],['value']
</code></pre>

<p>I have the following code at this time but nothing I tried for the loop worked...</p>

<pre><code>&lt;?php
//Read JSON file
$filename ='fichier.json';
$json = file_get_contents($filename);

//convert json object to php associative array
$data = json_decode($json,true);

// Loop trough the array
foreach(???) {
echo ???
}
?&gt;
</code></pre>