Read 338 times | Created 2014-06-26 06:25:40 | Updated 2014-06-26 06:25:40 | | |

 

<?php
function bacaHTML($url){
  // inisialisasi CURL
  $data = curl_init();
  // setting CURL
  curl_setopt($data, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($data, CURLOPT_URL, $url);
  // menjalankan CURL untuk membaca isi file
  $hasil = curl_exec($data);
  curl_close($data);
  return $hasil;
}
$kodeHTML = bacaHTML('http://www.klikbca.com');
$pecah = explode('<table width="139" border="0" cellspacing="0" cellpadding="0">', $kodeHTML);
$pecahLagi = explode('</table>', $pecah[2]);
echo "<div align='left'><strong>Data Kurs</strong></div>";
echo "<hr>";
echo "<table width='30px' border='0' cellpadding='5' class='kosong'>";
echo "<tr class='head'><td align='center' width=10px>KURS</td>";
echo "<td width=10px>JUAL</td><td width=10px>BELI</td></tr>";
echo $pecahLagi[0];
echo "</table>";
echo "<hr>";
$html = preg_replace('/<td.*?>(.*?)</td>/i', '$1',str_replace(" ","",$pecahLagi[0]));
$dummy=str_replace("nr","|",str_replace("<tr>",'',str_replace("</tr>",'',$html)));
$kurs=explode("||",$dummy);
$data='';
foreach($kurs as $k){
  $d=explode("nr",str_replace("|","",$k));
  $data.=trim(str_replace("n","|",$d[0]));
}
$hasil=explode('|',$data);
?>
<form id="form1" name="form1" method="post" action="">
<?php 
$num=count($hasil)-1;
for($i=1;$i<$num;$i++){
  echo "<input type='text' name='textfield$i' id='textfield$i' value='$hasil[$i]' />"
      .($i%3==0?'<br/>':'');
}
?>
</form>

demo : http://minerva.hol.es/ex/kurs.php