0

I would like to echo my datas from multi array JSON table.

My Code:

My JSON table:
[{"name1": 10},{"name2": 20},{"name3": 30}]


PHP:
foreach ($datas as $data) {
$offense_stat = json_decode($data['offense_stats'],true);
echo '
<tr>
  <th scope="row">'.translatePlayerName($data['player_id']).'</th> --not relevant now                                    
  <td>'.translatePositionName($data['position_id']).'</td> -- not relevant now

  <td>'.$offense_stat[0]->{'name1'}.'</td>
  <td>'.$offense_stat[1]->{'name2'}.'</td>
};
AlexSwamp
  • 11
  • 2
  • 2
    Possible duplicate of [How do I extract data from JSON with PHP?](https://stackoverflow.com/questions/29308898/how-do-i-extract-data-from-json-with-php) – Jonnix Feb 10 '19 at 15:26
  • 1
    Maybe you need `$offense_stat[0]['name1']` as you doing `json_decode` with `true` flag as second argument – dWinder Feb 10 '19 at 15:28

0 Answers0