简体   繁体   English

将PHP文件中的JSON编码数据打印到2列表中

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

Below are the results from PHP JSON encoded file. 以下是PHP JSON编码文件的结果。

[{"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>";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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