function calc_hana(){
$url = 'https://quotation-api-cdn.dunamu.com/v1/forex/recent?codes=FRX.KRWUSD';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
if(curl_errno($ch)){
throw new Exception(curl_error($ch));
}
curl_close($ch);
return $result;
}
$result_hana = calc_hana();
$datahana = json_decode($result_hana,ture);
$datahana = $datahana[0];
$_provider = $datahana['provider'];
$_buying = $datahana['cashBuyingPrice'];
$_selling = $datahana['cashSellingPrice'];
$_ttselling = $datahana['ttSellingPrice'];
$_ttbuyling = $datahana['ttBuyingPrice'];
$_usd = $datahana['basePrice'];
$_openusd = $datahana['openingPrice'];
$_chusd = $datahana['changePrice'];
$_openusd_o = $_usd - $_openusd;
$_openusd_op = ($_chusd/$_usd)*100;
$_openusd = round($_openusd,2);
<ul data-role="listview" data-count-theme="b" data-inset="true">
<li><h2><?=$_provider?></h2></li>
<li style="font-size: 14pt">환율 기준 (1 미국 달러)<br><?=$_openusd_p?></font></li>
<li style="font-size: 12pt">살때 : <?=sprintf('%0.2f',$_buying)?><br>
팔때 : <?=sprintf('%0.2f',$_selling)?><br>
보낼때 : <font color="#ff0000"><b><?=sprintf('%0.2f',$_selling)?></b></font><br>
받을때 : <?=sprintf('%0.2f',$_ttbuyling)?></li>
<li style="color:gray">Date: <?=$_datenew?></li>
</ul>
'웹 개발 이야기 > php' 카테고리의 다른 글
[PHP] 암호화 복호화 (0) | 2023.07.04 |
---|---|
[PHP] KISA API, Google translate API 이용하여 텍스트 번역하기 (0) | 2023.06.15 |
[PHP] php.ini - file upload 용량 설정하기 (0) | 2023.06.15 |
[PHP] php로 node.js 처럼 소켓 여는 법 (0) | 2023.06.15 |
[PHP] php + redis > session 관리로 대폭적인 성능향상 (0) | 2023.06.14 |
댓글