title: How do we properly print JSON output data in php?
body: <p>I'm using API to pull soccer data from betsapi. As I'm not expert in JSON, I'm sharing my queries here. My json output looks like this: </p>
  
  <pre><code>{  
  "success":1,
  "results":{  
    "season":{  
       "start_time":"1502402400",
       "end_time":"1526335199",
       "has_topgoals":"1",
       "has_leaguetable":"1",
       "has_lineups":"1",
       "name_1":"Premier League 17\/18",
       "name":"Premier League 17\/18"
    },
  
    "overall":{  
       "tournaments":[  
          {  
             "name":"Premier League",
             "rows":[  
                {  
                   "pos":"1",
                   "sort_pos":"1",
                   "change":"0",
                   "win":"8",
                   "draw":"1",
                   "loss":"0",
                   "goalsfor":"32",
                   "goalsagainst":"4",
                   "points":"25",
                   "pct":null,
                   "team":{  
                      "id":"708",
                      "name":"Man City",
                      "image_id":"17",
                      "cc":"gb"
                   }
                }
  
                {  
                   "pos":"20",
                   "sort_pos":"20",
                   "change":"0",
                   "win":"1",
                   "draw":"0",
                   "loss":"8",
                   "goalsfor":"2",
                   "goalsagainst":"19",
                   "points":"3",
                   "pct":null,
                   "team":{  
                      "id":"17189",
                      "name":"Crystal Palace",
                      "image_id":"7",
                      "cc":"gb"
                   }
                }
             ]
          }
       ]
    },
  </code></pre>
  
  <p>And my code to print result is </p>
  
  <pre><code>$obj = [''] // code above
  
  $obj = json_decode($data);
  
  foreach($obj as $result){
     echo $result-&gt;season-&gt;name; // or
  
     echo $result-&gt;overall-&gt;tournaments-&gt;name; // or
  }
  </code></pre>
  
  <p>Though I've tried it with many alternatives, it doesn't print anything neither does it gives any error.</p>
  
  <p>If anyone can point out the errors, I'd very much appreciate it.</p>