Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. {"status":"OK","data":{"trends":{"uv":[{"date":"201303","value":1},{"date":"201304","value":2},{"date":"201305","value":31},{"date":"201306","value":4},{"date":"201307","value":4},{"date":"201308","value":9},{"date":"201309","value":12},{"date":"201310","value":43},{"date":"201311","value":14},{"date":"201312","value":73},{"date":"201401","value":78},{"date":"201402","value":65},{"date":"201403","value":52}]},"trends_low_sample":false,"query_cost":13,"trends_frequency":"monthly"}}
  2.  
  3. $data1 = file_get_contents('/home/strj500/Downloads/result.html');
  4. //echo $data1;
  5.  
  6. $theData = json_encode($data1);
  7.  
  8. //$data1 = preg_replace('/,s*([]}])/m', '$1', utf8_encode($data1));
  9.  
  10. //$data1 = utf8_encode($data1);
  11.  
  12. $result1 = json_decode($theData);
  13.  
  14. echo $result1->status;
  15.  
  16. //var_dump($result1);
  17.  
  18. //echo json_last_error();
  19.  
  20. //echo error_log();
  21.  
  22. //echo error_reporting(E_ALL);
  23.  
  24. /*foreach ($result1->data->trends->rank as $rank
  25. {
  26. echo "{$rank->date}n";
  27. }*/
  28.  
  29. //echo $result1["data"]["trends"]["uv"];
  30.  
  31. <?php
  32. $json='{"status":"OK","data":{"trends":{"uv":[{"date":"201303","value":1},{"date":"201304","value":2},{"date":"201305","value":31},{"date":"201306","value":4},{"date":"201307","value":4},{"date":"201308","value":9},{"date":"201309","value":12},{"date":"201310","value":43},{"date":"201311","value":14},{"date":"201312","value":73},{"date":"201401","value":78},{"date":"201402","value":65},{"date":"201403","value":52}]},"trends_low_sample":false,"query_cost":13,"trends_frequency":"monthly"}}';
  33. $yourobj=json_decode($json);
  34. foreach($yourobj->data->trends->uv as $k=>$arr)
  35. {
  36. echo $arr->date."<br>";
  37. }
  38.  
  39. 201303
  40. 201304
  41. 201305
  42. 201306
  43. 201307
  44. 201308
  45. 201309
  46. 201310
  47. 201311
  48. 201312
  49. 201401
  50. 201402
  51. 201403
  52.  
  53. $result1 = json_decode($theData,true);
  54.  
  55. $result1['data']['trends']['uv'][0];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement