$valueA) { $foundKey = array_find_key_slash_insensitive($key, $b); if ($foundKey === null) { echo "[MISSING in B] [$key]\r\n"; continue; } $valueB = $b[$foundKey]; $outputLines[] = "[$foundKey] $valueB"; if (normalize($valueA) !== normalize($valueB)) { echo "[DIFF] [$key]\r\n"; echo " A: $valueA\r\n"; echo " B: $valueB\r\n"; } } // Extras aus B ans Ende foreach ($b as $key => $valueB) { if (array_find_key_slash_insensitive($key, $a) === null) { echo "[EXTRA in B] [$key]\r\n"; $outputLines[] = "[$key] $valueB"; } } // Datei schreiben $output = implode(PHP_EOL, $outputLines) . PHP_EOL; if ($bomB) { $output = "\xEF\xBB\xBF" . $output; } file_put_contents($fileC, $output); # --- function array_find_key_slash_insensitive($key, array $array) { $normalize = fn($str) => str_replace('/', '/', $str); $normalizedKey = $normalize($key); foreach ($array as $k => $_) { if ($normalize($k) === $normalizedKey) { return $k; // ← echter Key! } } return null; }