TransformProductCode.php 990 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. ini_set('display_errors', 1);
  3. ini_set('display_startup_errors', 1);
  4. error_reporting(E_ALL);
  5. header('Content-Type: application/json');
  6. $url = realpath("./../server/json/ProductCode.json");
  7. $json = file_get_contents($url);
  8. $json = json_decode($json);
  9. $productcode = str_replace("/", ".", $_GET["ProductCode"]);
  10. $productarray = explode(".", $productcode);
  11. //Fixwerte übernehmen:
  12. $fixwerte = 6;
  13. for($i = 0; $i < $fixwerte; ++$i){
  14. if(isset($productarray[$i])){
  15. $asocarray[$json->pattern[$i]->abk] = $productarray[$i];
  16. }
  17. else{
  18. $asocarray[$json->pattern[$i]->abk] = "";
  19. }
  20. }
  21. //Search which abk can be linked to the patternpart
  22. for($i = $fixwerte; $i < count($productarray); ++$i){
  23. foreach($json->pattern as $node){
  24. foreach($node->types as $type){
  25. if($productarray[$i] == $type){
  26. $asocarray[$node->abk] = $productarray[$i];
  27. }
  28. }
  29. }
  30. }
  31. echo json_encode($asocarray);
  32. ?>