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 && $type != "*"){ $asocarray[$node->abk] = $productarray[$i]; } } } } } else{ $i = 0; foreach($json->pattern as $node){ if(isset($productarray[$i])){ $asocarray[$node->abk] = $productarray[$i]; } ++$i; } } if(!array_key_exists("Pf", $asocarray)){ $asocarray["Pf"] = "KeineAngabePf"; } if(!array_key_exists("Va", $asocarray)){ $asocarray["Va"] = "KeineAngabeVa"; } if(!array_key_exists("Kf", $asocarray)){ $asocarray["Kf"] = "KeineAngabeKf"; } if(!array_key_exists("Zi", $asocarray)){ $asocarray["Zi"] = "KeineAngabeZi"; } if($asocarray["Pf"] == ""){ $asocarray["Pf"] = "KeineAngabePf"; } if($asocarray["Va"] == ""){ $asocarray["Va"] = "KeineAngabeVa"; } if($asocarray["Kf"] == ""){ $asocarray["Kf"] = "KeineAngabeKf"; } if($asocarray["Zi"] == ""){ $asocarray["Zi"] = "KeineAngabeZi"; } echo json_encode($asocarray); ?>