foreach - PHP JSON to Array Error -


i have code:

$decode_datab = json_decode($grab_datab, true); $unranked = '';  foreach($decode_datab->playerstatsummaries $summary){     if($summary->playerstatsummarytype == 'unranked'){         $unranked = $summary;         break;     } } 

for reason, can't figure out, $decode_datab doesn't work foreach(). have tried $decode_datab = json_decode($grab_datab); works uses of website, errors.

any great! in advance

edit:

someone wanted $grab_datab although has nothing error:

$instance = new riotapi($region); $grab_datab = $instance->getstats($grab_id); 

uh... you're passing true second parameter, thereby getting associative array.

why, then, treating object? -> getting object properties.

foreach($decode_datab['playerstatsummaries'] $summary){     if($summary['playerstatsummarytype'] == 'unranked'){         $unranked = $summary;         break;     } } 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -