48719181 - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of 48719181.php

  1. <?php
  2. $ComputerMapping[0]["PrinterName"] = "PRT01_Zentral";
  3. $ComputerMapping[0]["PrintServer"] = "DC01";
  4. $ComputerMapping[0]["isDefaultPrinter"] = 0;
  5.  
  6. $ComputerMapping[1]["PrinterName"] = "PRT02_BH";
  7. $ComputerMapping[1]["PrintServer"] = "DC01";
  8. $ComputerMapping[1]["isDefaultPrinter"] = 1;
  9.  
  10. $ComputerMapping[2]["PrinterName"] = "PRT03_EDV";
  11. $ComputerMapping[2]["PrintServer"] = "DC01";
  12. $ComputerMapping[2]["isDefaultPrinter"] = 0;
  13.  
  14. $ComputerMapping[3]["PrinterName"] = "PRT04_GL";
  15. $ComputerMapping[3]["PrintServer"] = "DC01";
  16. $ComputerMapping[3]["isDefaultPrinter"] = 0;
  17.        
  18. $UserMapping[0]["PrinterName"] = "PRT01_Zentral";
  19. $UserMapping[0]["PrintServer"] = "DC01";
  20. $UserMapping[0]["isDefaultPrinter"] = 0;
  21.        
  22. $UserMapping[1]["PrinterName"] = "PRT02_BH";
  23. $UserMapping[1]["PrintServer"] = "DC01";
  24. $UserMapping[1]["isDefaultPrinter"] = 0;
  25.  
  26. $UserMapping[2]["PrinterName"] = "PRT03_EDV";
  27. $UserMapping[2]["PrintServer"] = "DC01";
  28. $UserMapping[2]["isDefaultPrinter"] = 1;
  29.  
  30. function array_merge_recursive_distinct( array &$array1, array &$array2 ) {
  31. $merged = $array1;
  32. foreach ($array2 as $key => &$value)
  33. {
  34.     if (is_array($value) && isset($merged[$key]) && is_array($merged[$key]))
  35.     {
  36.         $merged[$key] = array_merge_recursive_distinct($merged[$key], $value);
  37.     }
  38.     else
  39.     {
  40.         $merged[$key] = $value;
  41.     }
  42. }
  43. return $merged;
  44. }
  45.  
  46. $Result = array_merge_recursive_distinct($ComputerMapping, $UserMapping);
  47.  
  48. print_r ($Result);
File Description
  • 48719181
  • PHP Code
  • 10 Feb-2018
  • 1.4 Kb
You can Share it: