pattern[$i]->abk] = $productarray[$i]; } else{ $asocarray[$json->pattern[$i]->abk] = ""; } } //Search which abk can be linked to the patternpart for($i = $fixwerte; $i < count($productarray); ++$i){ foreach($json->pattern as $node){ foreach($node->types as $type){ if($productarray[$i] == $type){ $asocarray[$node->abk] = $productarray[$i]; } } } } echo json_encode($asocarray); ?>