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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -