Create table stats from Json

jonnypixel

I have a Json result like so

{"goals":["1","1"],"minutes":["12","34"],"player":["1","1"]} 

And i am trying to create a table with rows displaying each stat like so

Goals Minutes Player

1     12        1

1     34        1

I currently have this code written up and although i am getting teh data its not quite working the way i want it to. Im not so clued up on Json and the displaying of it as you can see.

<?php

$jsonresult =  $this->item->results;

$phpArray = json_decode($jsonresult, true);

foreach ($phpArray as $key => $value) {

foreach ($value as $k => $v) {

?>

 <tr><td><?php echo $v; ?></td></tr>


<?php }} ?>

Cheers Jonny

FuzzyTree
<?php

$json = '{"goals":["1","1"],"minutes":["12","34"],"player":["1","1"]}';
$array = json_decode($json,true);

print_r($array);    

print "Goals, Minutes, Player\n";

foreach($array['goals'] as $key => $value) {
  print $value . ',' 
  . $array['minutes'][$key] . ','
  . $array['player'][$key] . "\n";
}

Output

Goals, Minutes, Player
1,12,1
1,34,1

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Create <ul> from JSON with jQuery

来自分类Dev

Manually create Latex Regression Table from R

来自分类Dev

Is it possible to create a Parse object from JSON

来自分类Dev

在Oracle过程中交换分区后的dbms_Stats.Gather_Table_Stats?

来自分类Dev

Gather_table_stats始终更新统计信息

来自分类Dev

Create a pivot table with PostgreSQL

来自分类Dev

通过EXECUTE IMMEDIATE以字符串形式执行时如何解决存储过程未执行dbms_stats.gather_table_stats()的问题

来自分类Dev

为什么SELECT FROM sys.dm_db_index_usage_stats返回两行/表?

来自分类Dev

JSON Create a unique link

来自分类Dev

Insert values from A table to A table

来自分类Dev

Python/Pandas: create summary table

来自分类Dev

获取MySQL CREATE TABLE的结果

来自分类Dev

Working with data from table

来自分类Dev

SELECT FROM table,ORDER BY IF(...)

来自分类Dev

来自Ajax的Bootstrap Table json

来自分类Dev

用JSON反应make table

来自分类Dev

From monthly table to daily table in Bigquery

来自分类Dev

inserting table values from one table to another

来自分类Dev

Getting "High Score" table from score table

来自分类Dev

SQLite: create table and add a row if the table doesn't exist

来自分类Dev

DECLARE TABLE和CREATE TABLE有什么区别?

来自分类Dev

未知列类型的Postgres CREATE TABLE AS SELECT

来自分类Dev

Hibernate创建错误的create table语句?

来自分类Dev

CREATE TABLE SQL查询的语法错误

来自分类Dev

TSQL:CREATE TABLE内的NOCHECK外键

来自分类Dev

Create view to non-existent table

来自分类Dev

SQL新手,CREATE TABLE错误

来自分类Dev

SQLite syntax to create index on a temp table?

来自分类Dev

Attempting to create anova table with unequal sizes R