I have a table.html, data.php and json.csv within the same folder.
data.php is doing fopen(\"json.csv\",\"r\")
to read f
Here I have taken json data in to $json variable, and then use foreach loop to create table from json data.
foreach ($data as $key => $jsons) {
$table ='';
foreach ($jsons as $rkey => $rvalue) {
if($rkey=='head')
{
$table.='';
foreach($rvalue as $rvv)
{
$table.=''.$rvv.' ';
}
$table.=' ';
}else
if($rkey=='rows')
{
foreach($rvalue as $rvv)
{
$table.='';
foreach($rvv as $rv)
{
$table.=''.$rv.' ';
}
$table.=' ';
}
}
}
}
echo $table;
?>
I have taken reference from http://www.tutsway.com/create-table-from-json.php
- 热议问题