<span style= "FONT-SIZE:18PX;" ><?php# Set the encoding header ("Content-type:text/html;charset=utf-8"), #判断 receive if (Isset ($_post[' submit '))) {#接收数据 $type = $_post[' type ']; #火车类型 $start = UrlEncode ($_post[' start '); #起始站 $end = UrlEncode ($_post[' end '); #终点站 # Create url# view trips with the http://apis.juhe.cn/train/s?name=g4&key=1f9daa1525abbf6a8d032d439bcbd3bf&dtype= json&start={$start}&end={$end}&traintype={$type} ";//View station times//$url =" Http://apis.juhe.cn/train/s2s? start={$start}&end={$end}&traintype={$type}&key=1f9daa1525abbf6a8d032d439bcbd3bf "; #获取数据 $str = File_ Get_contents ($url); #对json数据进行转换 $str 1 = json_decode ($STR); Get an object $str2 = Json_decode ($str, true); Get an array of echo ' <pre> ';//Var_dump ($str 1, $str 2); #进行数据遍历 trips foreach ($str 1->result->train_info as $info) { Echo ' train information '. $info. ' <br> '; Echo '
Train Trips Enquiry