Raju  Dudhrejiya Raju Dudhrejiya - 1 year ago 92
JSON Question

How to convert json data to array in php?

I have json string live below, I try to convert array but I am not success can anyone please help me, thank you advance.

Example 1 : s:59:"[{"item_id":"UTILITY CON CERNIERA","qty":1,"points":"110"}]";

Example 1 : s:109:"[{"item_id":"UTILITY CON CERNIERA","qty":1,"points":"110"},{"item_id":"PESA VALIGIA","qty":1,"points":"120"}]";

Answer Source

Your data is serialized as well as json encoded. So you have to use:-

json_decodealong with unserialize like below:-


$data = 's:59:"[{"item_id":"UTILITY CON CERNIERA","qty":1,"points":"110"}]"';



$data = 's:109:"[{"item_id":"UTILITY CON CERNIERA","qty":1,"points":"110"},{"item_id":"PESA VALIGIA","qty":1,"points":"120"}]"';

https://eval.in/590757 And https://eval.in/590758

For more reference:-



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