I think I’ve found where the error lies:
$convertJSON = file_get_contents("http://www.google.com/ig/calculator?hl=en&q=" . $currencyValue . $currencySelectValue . "%3D%3FUSD", true);
var_dump($convertJSON);
$convertArr = json_decode($convertJSON, true);
var_dump($convertArr);
I do that to debug, and I get this result (I entered 555 and Euros):
string(68) "{lhs: "555 Euros",rhs: "796.64700 U.S. dollars",error: "",icc: true}"
NULL
So it seems that the PHP function to decode the JSON object is doing something wrong somewhere. Any help?
The response Google is giving you isn’t valid JSON because the labels are not quoted. You’ll have to parse it yourself.
Output: