Skip to content
Advertisement

Could not decode the JSON string using PHP

I could not convert the JSON string to array using PHP. Here is my code:

JavaScript

The above line is giving the below output.

JavaScript

I need to convert this to array using below code.

JavaScript

But here I am getting the output as (empty). I need to convert the above string to array.

Advertisement

Answer

You json string is not a valid json. It have extra ' on both side of the string.

From your echo result the ' is output on each side of the string. For a json string the ' shoudn’t be there.

You can check the live demo here have a good understanding.

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