本文共 1331 字,大约阅读时间需要 4 分钟。
//格式化输出函数 function p( $temp){ echo "
"; print_r($temp); die; } $my_arr= array('USD','EURUSD','GBPUSD','USDJPY','AUDUSD','USDCHF','USDCAD','USDHKD','USDCNY'); $json_my=file_get_contents('http://quote.fx678.com/assets/interface/quotes.php?exchName=WH&st=0.3367746297735721'.time()); $my_arr2=json_decode($json_my,true); for($i=0; $i$my_arr2['i'][$i], 't'=>$my_arr2['t'][$i], 'c'=>$my_arr2['c'][$i], 'o'=>$my_arr2['o'][$i], 'h'=>$my_arr2['h'][$i], 'l'=>$my_arr2['l'][$i], 'b'=>$my_arr2['b'][$i], 'se'=>$my_arr2['se'][$i], 'p'=>$my_arr2['p'][$i], 'v'=>$my_arr2['v'][$i], ); } foreach($my_arr as $p1=>$v1){ foreach($data as $k=>$v){ if ($v['i']==$v1){ $data1[]=$v; } } } $txt2=" 名称 最新价 涨跌 开盘价 最高 最低 昨收 更新时间"; foreach($data1 as $k=>$v){ if($v['i']=='USD') { $name="美元指数"; } elseif($v['i']=='EURUSD') { $name="欧元美元"; } elseif($v['i']=='GBPUSD') { $name="英镑美元"; } elseif($v['i']=='USDJPY') { $name="美元日元"; } elseif($v['i']=='AUDUSD') { $name="澳元美元"; } elseif($v['i']=='USDCHF') { $name="美元瑞士"; } elseif($v['i']=='USDCAD') { $name="美元加元"; } elseif($v['i']=='USDHKD') { $name="美元港元"; } elseif($v['i']=='USDCNY') { $name="美元人民币"; } $txt2.=" ".$name." ".round($v['c'],2)." ".round(($v['h']-$v['l']),2)." ".round($v['o'],2)." ".round($v['h'],2)." ".round($v['l'],2)." ".round($v['c'],2)." ".date('H:i:s', $v['t']).""; } //p($data1); echo $txt2;转载地址:http://lxifo.baihongyu.com/