在PHP中访问Json

时间:2013-02-07 05:53:23

标签: php json

//Decoded Json data
object(stdClass)[250]
  public '2013-02-05' =>
    object(stdClass)[114]
      public 'bounce_count' => int 1
      public 'avg_time_on_site' => int 237
  public '2013-02-06' =>
    object(stdClass)[115]
      public 'bounce_count' => int 6
      public 'avg_time_on_site' => int 983
$json_data=json_decode($result);
//$result has the json string 

如何检索特定日期的bounce_count,avg_time_on_site以及日期将在php中更改的日期。

1 个答案:

答案 0 :(得分:2)

$json_data=json_decode($result, true);

foreach($json_data as $date=>$val){

   echo "Date : ".$date;
   echo "bounce_count : ".$val['bounce_count'];
   echo "avg_time_on_site : ".$val['avg_time_on_site'];
   echo "===========================<br>";
}