Currency convertor with PHP

function currency_convert($amount, $from, $to){
    $result = file_get_contents("https://www.google.com/finance/converter?a=$amount&from=$from&to=$to");
    $result = explode("<span class=bld>",$result);
    $result = explode("</span>",$result[1]);  
    $converted_amount = preg_replace("/[^0-9\.]/", null, $result[0]);
    echo $converted_amount;
}

currency_convert(1,'gbp','usd');

Leave a Reply

Your email address will not be published. Required fields are marked *