Dale Nguyen Dale Nguyen -4 years ago 94
PHP Question

Convert String to Json in PHP from GET Request

When run GET request, the site returns a string instead of JSON with a question mark in the beginning of the string.

?({ "Years": {"min_year":"1941", "max_year":"2017"} });

I tried to use json_encode() function in PHP. However, it returns NULL.

The results is from this site: https://www.carqueryapi.com/api/0.3/?callback=?&cmd=getYears

Does anyone know how to convert the result into JSON? Thanks,

Answer Source

If you grab the results from the URL without the callback parameter, you can get the standard JSON format.


{ "Years": {"min_year":"1941", "max_year":"2017"} }

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download