- file_get_contents: documentation ( source)
- json_decode: documentation ( source)
- bcmul: documentation ( source)
- preg_match: documentation ( source)
- preg_replace: documentation ( source)
<?php
function _CC($amt,$from=''){
global $CURRENCY;
if($CURRENCY['conv']===1){
$from=(!empty($from) ? $from : 'USD');
if(empty($CURRENCY[$from])){
$c=file_get_contents('http://www.google.com/ig/calculator?hl=en&q=1'.$from.'=?'.LOCAL_CURRENCY);
$j=json_decode(preg_replace('/({|,)([a-z]+): /','$1"$2": ',$c));
preg_match('/\d+(?:\.\d+)?/',$j->{'rhs'},$res);
$CURRENCY[$from] = $res[0];
}
return bcmul($amt,$CURRENCY[$from],2);
}else{
return $amt;
}
}
_CC('1.11');