Parse a JSON (array with tabs and arrays) with PHP -
i have been trying parse json response since few days without success. i've read on internet , site how parse foreach think structure of json different examples i've found. here json:
array(1) { ["matches"]=> array(10) { [0]=> array(13) { ["matchid"]=> int(2125878813) ["region"]=> string(3) "euw" ["platformid"]=> string(4) "euw1" ["matchmode"]=> string(7) "classic" ["matchtype"]=> string(12) "matched_game" ["matchcreation"]=> float(1432656547642) ["matchduration"]=> int(1852) ["queuetype"]=> string(15) "ranked_solo_5x5" ["mapid"]=> int(11) ["season"]=> string(10) "season2015" ["matchversion"]=> string(9) "5.9.0.318" ["participants"]=> array(1) { [0]=> array(10) { ["teamid"]=> int(200) ["spell1id"]=> int(7) ["spell2id"]=> int(4) ["championid"]=> int(67) ["highestachievedseasontier"]=> string(8) "platinum" ["timeline"]=> array(9) { ["creepspermindeltas"]=> array(3) { ["zerototen"]=> float(6.2) ["tentotwenty"]=> float(7.4) ["twentytothirty"]=> float(4.4) } ["xppermindeltas"]=> array(3) { ["zerototen"]=> float(336.2) ["tentotwenty"]=> float(428.3) ["twentytothirty"]=> float(396) } ["goldpermindeltas"]=> array(3) { ["zerototen"]=> float(270.7) ["tentotwenty"]=> float(363.6) ["twentytothirty"]=> float(294.8) }
if understand array tabs inside , arrays ?
i example display 10 matches id : matches->matchid matches->participants->championid matches->participants->timeline->creepspermindeltas->zerototen
here i've done far display matchid
:
$decodehisto = json_decode ($resulthisto,true); //var_dump($decodehisto); foreach ($decodehisto{[matches]} $d) { echo $d->{[matchid]}-; }
can me please ?
your code not json, json defined this:
{ "herausgeber": "xema", "nummer": "1234-5678-9012-3456", "deckung": 2e+6, "waehrung": "euro", "inhaber": { "name": "mustermann", "vorname": "max", "maennlich": true, "hobbys": [ "reiten", "golfen", "lesen" ], "alter": 42, "kinder": [], "partner": null } }
you can convert json array php code:
$array = json_decode($json);
but said before, code not json. seems php array. can access with:
$arr["matches"][0]["matchid"]
for example.
Comments
Post a Comment