<?php
class currencyCoverter
{
public $fromCurr = 'USD';
public $toCurr = 'INR';
function __construct($amount, $to, $from)
{
if(intval($amount) > 0){
$this->amount = intval($amount);
}
if(trim($to) != ''){
$this->toCurr = $to;
}
if(trim($from) != ''){
$this->fromCurr = $from;
}
}
function getUpadte()
{
$returnHtml = array();
$page = 'http://www.google.com/search?&q='.$this->amount.'+' . $this->fromCurr . '+in+' . $this->toCurr;
$returnRawHtml = file_get_contents( $page );
preg_match_all('/<h2 class=r(.*)\<\/h2\>/Uis',$returnRawHtml,$returnHtml,PREG_PATTERN_ORDER);
if (isset($returnHtml[0][0]))
{
$gRate = strip_tags($returnHtml[0][0]);
return $gRate;
}
else {
return false;
}
}
}
?>