How to loop through this json decoded data in PHP?

后端 未结 5 997
一向
一向 2020-12-10 21:40

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

\"[{\"productId\":\"epIJp9\",\"name\":\"Product A\",\"amount\":\"5\",\"identifier\":\"242\         


        
5条回答
  •  时光说笑
    2020-12-10 22:09

    You can try the code at php fiddle online, works for me

     $list = '[{"productId":"epIJp9","name":"Product A","amount":"5","identifier":"242"},{"productId":"a93fHL","name":"Product B","amount":"2","identifier":"985"}]';
    
    $decoded_list = json_decode($list); 
    
    echo count($decoded_list);
    print_r($decoded_list);
    

提交回复
热议问题