JSON values into HTML table

前端 未结 3 977
青春惊慌失措
青春惊慌失措 2021-02-10 15:47

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

3条回答
  •  猫巷女王i
    2021-02-10 16:20

    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.='';
            }
            $table.='';
        }else
        if($rkey=='rows')
        {
            foreach($rvalue as $rvv)
            {
                $table.='';
                foreach($rvv as $rv)
                {
                    $table.='';
                }
                $table.='';
            }
        }
     }
    }
    echo $table;
    ?>
    

    I have taken reference from http://www.tutsway.com/create-table-from-json.php

    提交回复
    热议问题
    '.$rvv.'
    '.$rv.'