简体   繁体   中英

Printing JSON encoded data from PHP file into a 2 column table

Below are the results from PHP JSON encoded file.

[{"type":"pie","name":"Class","data":[["Nari",70],["Giri",45],["Balu",25],["Babu",82]]}]

I want to print data values into two column table.

| nari | 70 |  
| giri | 45 |   
| balu | 25 |  
| babu | 82 |   

It's a pitty that you don't show you attempts so far. On the other hand it's shortly before christmas so...

$json = '[{"type":"pie","name":"Class","data":[["Nari",70],["Giri",45],["Balu",25],["Babu",82]]}]';
$object = json_decode($json);
foreach($object[0]->data as $row) {
  echo "|".strtolower($row[0])."|".strtolower($row[1])."|<br>";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM