How to parse JSON string in php

后端 未结 5 1134
你的背包
你的背包 2021-01-03 16:56

I\'m getting below JSON response:

[{\"startDate\":\"2012-07-12 11:21:38 +0530\",\"totalTime\":0},{\"startDate\":\"2012-07-11 11:27:33 +0530\",\"totalTime\":0         


        
5条回答
  •  借酒劲吻你
    2021-01-03 17:10

    As everyone said, and you did - use json_decode.

        $dateArrays  = json_decode($dateTimeArr, true); // decode JSON to associative array
        foreach($dateArrays as $dateArr){
            echo $dateArr['startDate']; 
            echo $dateArr['totalTime']; 
        }
    

    In future, if you are unsure what type or structure of data is in the variable, do var_dump($var) and it will print type of variable and its content.

提交回复
热议问题