I'm trying to print the distance in km between two ZIP codes, using this Zip Code API.
My code:
$settings = json_decode(file_get_contents('https://www.zipcodeapi.com/rest/rDJ7VmDHWP7NVwCXRbznkauB5DddKBQbeAjaWXSSM0FIxiFoueMPohquUDIFfzQt/distance.json/45410/45412/km'), true);
print_r($settings['distance']);
When I visit the actual link, it returns the expected result of 3.635 km. However, the code actually prints out seemingly random numbers, such as 17.04, 90.79, and 46.33 (my last 3 attempts).
I am running this on Cloud9, I have tried isolating it on a new page.
Am I I using json_decode wrong or does this seem like an issue with the API?
3.635.<br><b>test</b>. Visiting the actual site gives you correct info, but I just discovered that getting requests from the API without registering on their site will generate random numbers. Quite silly, but once I registered it worked with my new key.