| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2546 人关注过本帖
标题:json数据无法循环输出,各位大神帮我看看!
只看楼主 加入收藏
centos
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2019-12-28
收藏
 问题点数:0 回复次数:1 
json数据无法循环输出,各位大神帮我看看!
程序代码:
<?php   
header('Content-type:text/json');
$url_online = file_get_contents('https://');
//打印json数据
$jsondata = json_decode($url_online,true);
//格式化json数据为array数组

//数据循环读取;
foreach($jsondata['data']['list'] as $datass){
$lottery_date = $datass['lottery_date'];
$time = date("Y-m-d H:i:s", $lottery_date);
$lottery = array();
$lottery['expect'] = $datass['lottery_id'];
$lottery['opencode'] = $datass['lottery_numbers'];
$lottery['opentime'] = $time;
$data = ["row" => "10","code" => "tx28","info" => "null","data" => $lottery] ;
}
$json = json_encode($data,true);
echo $json;
?>


data数组无法循环写出,请问怎么才能解决这问题?
搜索更多相关主题的帖子: 循环 data array 输出 数据 
2019-12-28 05:41
孙kongkong
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-3-19
收藏
得分:0 
<?php
header('Content-type:text/json');
$url_online = file_get_contents('https://');
//打印json数据
$jsondata = json_decode($url_online,true);
//格式化json数据为array数组

//数据循环读取;
$data = [];
foreach($jsondata['data']['list'] as $datass){
$lottery_date = $datass['lottery_date'];
$time = date("Y-m-d H:i:s", $lottery_date);
$lottery = array();
$lottery['expect'] = $datass['lottery_id'];
$lottery['opencode'] = $datass['lottery_numbers'];
$lottery['opentime'] = $time;
$data[] = ["row" => "10","code" => "tx28","info" => "null","data" => $lottery] ;
}
$json = json_encode($data,true);
echo $json;
?>
2020-03-19 19:09
快速回复:json数据无法循环输出,各位大神帮我看看!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024924 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved