[Solved] How can I show array in table?


There are many tutorials based on Array, which you need to go through it for basic understanding.

Quick Start

Code

<?php
$arr["2016-10-26"] = ['abc'=> 0, 'def'=> 0, 'xyz'=> 0];
$arr["2016-10-27"] = ['abc'=> 0, 'def'=> 0, 'xyz'=> 0];

print_r($arr);
?>

<table>
  <tr>
    <th>Date</th>
    <th>abc</th>
    <th>def</th>
    <th>xyz</th>
  </tr>
  <?php foreach($arr as $key=>$val){?>
  <tr>
    <td><?=$key;?></td>
    <td><?=$val['abc']?></td>
    <td><?=$val['def']?></td>
    <td><?=$val['xyz']?></td>
  <?php }?>
  </tr>
</table>

Output

Array ( [2016-10-26] => Array ( [abc] => 0 [def] => 0 [xyz] => 0 )
[2016-10-27] => Array ( [abc] => 0 [def] => 0 [xyz] => 0 ) )

Date       abc  def xyz
2016-10-26  0   0   0
2016-10-27  0   0   0

0

solved How can I show array in table?