Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. {
  2. "11153" : {
  3. "sub" : {
  4. "11411" : {
  5. "id" : "994834",
  6. "source_api" : "all",
  7. "tanggal" : "2016-06-14",
  8. "instansi_id" : "11411",
  9. "belum" : "12",
  10. "proses" : "23",
  11. "selesai" : "7",
  12. "parent_nid" : "11153",
  13. "InstansiName" : "Dinas PSDA dan ESDM Kota Semarang",
  14. "sub" : [],
  15. "rtl" : "5.30"
  16. },
  17. }
  18. }
  19. }
  20.  
  21. <?php
  22. $data = '{
  23. "11153" : {
  24. "sub" : {
  25. "11411" : {
  26. "id" : "994834",
  27. "source_api" : "all",
  28. "tanggal" : "2016-06-14",
  29. "instansi_id" : "11411",
  30. "belum" : "12",
  31. "proses" : "23",
  32. "selesai" : "7",
  33. "parent_nid" : "11153",
  34. "InstansiName" : "Dinas PSDA dan ESDM Kota Semarang",
  35. "sub" : [],
  36. "rtl" : "5.30"
  37. }
  38. }
  39. }
  40. }'; // initial data
  41.  
  42. $new_array = json_decode($data,true); // decode data to convert it to array
  43. echo "<pre/>";print_r($new_array); // print the array
  44. echo $new_array[11153]['sub'][11411]['belum'];// you can print others like this
  45.  
  46. $array=json_decode($json_string,true);
  47.  
  48. <?php
  49. echo $array["11153"]["sub"]["11411"]["belum"]; // get belum
  50. echo $array["11153"]["sub"]["11411"]["proses"]; // get proses
  51. echo $array["11153"]["sub"]["11411"]["selesai"]; // selesai
  52.  
  53. <?php
  54. echo $array["arraykey"][0];
  55.  
  56. <?php
  57. for($i=0;$i<sizeof($array["arraykey"]);$i++) {
  58. echo $array["arraykey"][$i];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement