Advertisement
Eliaseeg

Iterate through JSON

Dec 29th, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2. $json = json_decode('{  
  3.   "transformice":{  
  4.      "gb":[  
  5.         "Shamousey",
  6.         "Thooyafluffy"
  7.      ],
  8.      "nl":[  
  9.         "Distances"
  10.      ],
  11.      "de":[  
  12.         "Nachtfell",
  13.         "Perlchen",
  14.         "Notearl"
  15.      ],
  16.      "ar":[  
  17.         "Error_404",
  18.         "Kamelotepica",
  19.         "Cagataymylov"
  20.      ],
  21.      "es":[  
  22.         "Hidrolisis"
  23.      ],
  24.      "vk":[  
  25.         "Dewilheart"
  26.      ],
  27.      "hu":[  
  28.         "Lunacska"
  29.      ]
  30.   },
  31.   "bouboum":{  
  32.      "gb":[  
  33.         "Shamousey"
  34.      ]
  35.   },
  36.   "fortoresse":{  
  37.      "gb":[  
  38.         "Shamousey"
  39.      ]
  40.   },
  41.   "nekodancer":{  
  42.      "gb":[  
  43.         "Shamousey"
  44.      ]
  45.   }
  46. }');
  47.  
  48. foreach($json as $key=>$val){
  49.     foreach($val as $k=>$v){
  50.         foreach($json->transformice->$k as $name) {
  51.             echo $k . " : " .$name . "<br>";
  52.         }
  53.     }
  54. }
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement