Ada yang tau salahnya dimana sama function curl ini ?

Siang semua,

Mau tanya ada yang tau salahnya function ini dimana ?

Sebelumnya sih lancar-lancar aja, tapi belakangan ini error ngga kebaca ratenya.

Udah coba otak-atik masih belum ada perubahan.

 <?php

function bacaHTML($url){

    $data = curl_init();

    curl_setopt($data, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($data, CURLOPT_URL, $url);

    $hasil = curl_exec($data);
    curl_close($data);
    return $hasil;
}

function getTTCounterJual($response, $mataUang) {
  preg_match("%<table.*?Mata Uang(.*?)</table>%s",
  $response, $matches);
$pecah = explode('<td align="center" style="background-color: white">JPY</td>', $matches[1]);
//print_r($pecah);
$pecah2 = explode ('<td align="center" style="background-color: white">SAR</td>',$pecah[1]);
//print_r($pecah2);
$pecah3 = explode ('<td style="background-color: white">',$pecah2[0]);
$pecah4 = explode ('</td>',$pecah3[3]);
//print_r($pecah4[0]);
return $pecah4[0];
}

function getBankNotesJual($response, $matauang) {
    preg_match("%<table.*?Mata Uang(.*?)</table>%s",
  $response, $matches);
$pecah = explode('<td align="center" style="background-color: white">JPY</td>', $matches[1]);
//print_r($pecah);
$pecah2 = explode ('<td align="center" style="background-color: white">SAR</td>',$pecah[1]);
//print_r($pecah2);
$pecah3 = explode ('<td style="background-color: white">',$pecah2[0]);
$pecah4 = explode ('</td>',$pecah3[5]);
//print_r($pecah4[0]);
return $pecah4[0];
}

$response =  bacaHTML('http://www.bca.co.id/Individu/Sarana/Kurs-dan-Suku-Bunga/Kurs-dan-Kalkulator');

if(getBankNotesJual($response, 'JPY')>getTTCounterJual($response, 'JPY'))
$rate = getBankNotesJual($response, 'JPY');
else $rate = getTTCounterJual($response, 'JPY');
$ratebca = str_replace(",",".",$rate);
?>
<h2><? echo "JPY $ratebca"; ?></h2>

Terimakasih sebelumnya :)

avatar addit93
@addit93

1 Kontribusi 0 Poin

Diperbarui 6 tahun yang lalu

2 Jawaban:

Permisi mas @adit

avatar gugunguntoro
@gugunguntoro

250 Kontribusi 10 Poin

Dipost 6 tahun yang lalu

Jawaban Terpilih

Coba tambahin

 curlopt_followlocation
avatar zeeb
@zeeb

60 Kontribusi 19 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban