Skip to content
Advertisement

How to decode JSON when using PHP multi_curl

I’m trying to access data on the internet via an AJAX and using PHP. I’ve managed to access to data, however, it is JSON encoded. I want to decode the results.

PHP File:

JavaScript

If you replace ‘json_encode($output)’ with ‘json_decode($output)’ or just ‘$output’ doesn’t work as it returns null with console.log().

JavaScript File:

JavaScript

Data Returned is JSON encoded:

JavaScript

Desired Data Formatting is JSON decoded:

JavaScript

Advertisement

Answer

The Final Output should be

JavaScript

The response from the remote api server is STRING json and we need to decode it before marge it to array

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement