I\'ve have this list of products in JSON that needs to be decoded:
\"[{\"productId\":\"epIJp9\",\"name\":\"Product A\",\"amount\":\"5\",\"identifier\":\"242\
Try like following codes:
$json_string = '[{"productId":"epIJp9","name":"Product A","amount":"5","identifier":"242"},{"productId":"a93fHL","name":"Product B","amount":"2","identifier":"985"}]';
$array = json_decode($json_string);
foreach ($array as $value)
{
echo $value->productId; // epIJp9
echo $value->name; // Product A
}
echo count($array); // 2