Below code was working fine on Production from last few months. Recently it started breaking.
Yesterday it was giving HTTP error issue for file_get_contents
function.
Today, On Execution it shows Undefined Offset error.
I am not sure what has changed for Finance Google API.
public function getJPYtoUSDExchangeRate(){
$from = 'JPY';
$to = 'USD';
$amount = 1;
$data = file_get_contents("https://finance.google.com/finance/converter?a=$amount&from=$from&to=$to");
preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted);
$converted = preg_replace("/[^0-9.]/", "", $converted[1][0]);
return number_format(round($converted, 3),2);
}