Read 334 times | Created 2014-06-10 08:04:00 | Updated 2014-06-10 08:37:47 | | |

 

<?php
/*********************************
FILENAME    : goldsilver.php
CREATE BY   : cahya dsn
PURPOSE     : grab gold and silver price 
CREATE DATE : 2014-06-10
**********************************/
$URL='https://www.antamgold.com/embed/';
$text = file_get_contents($URL);
$grab=explode('<script language="javascript">', $text);
$data=str_replace("CSSSource=\"https://www.antamgold.com/\"","",$grab[1]);
preg_match_all('/Info.Price[\d]\.[a-z]+\=\'(.*?)\'\;/', $data, $grab);
$n=count($grab[1])/3;
$data=array();
for($i=0;$i<$n;$i++){
  $data[]=array('nama'=>$grab[1][$i*3+0],'jual'=>$grab[1][$i*3+1],'beli'=>$grab[1][$i*3+2]);
}
print_r($data);