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数组无法循环写出,请问怎么才能解决这问题?