<?php $json = ' { "toppings": [ { "id": "5002", "type": "Glazed" }, { "id": "5006", "type": "Chocolate" }, { "id": "5002", "type": "Glazed" } ] }'; $items = json_decode($json); $searchIds = [5002,5006]; foreach($searchIds as $search) { foreach($items->toppings as $item) { if($item->id == $search) { echo $item->type; } break; } continue; }
You have javascript disabled. You will not be able to edit any code.