Kaltsoon Kaltsoon - 3 months ago 20
JSON Question

How to loop through this json decoded data in PHP?

I've have this list of products in JSON that needs to be decoded:

"[{"productId":"epIJp9","name":"Product A","amount":"5","identifier":"242"},{"productId":"a93fHL","name":"Product B","amount":"2","identifier":"985"}]"

After I decode it in PHP with
, I have no idea what kind of structure the output is. I assumed that it would be an array, but after I ask for
it says its "0". How can I loop through this data so that I get the attributes of each product on the list.



To convert json to an array use

 json_decode($json, true);