3v4l.org

run code in 500+ PHP versions simultaneously
<?php function print_line(string $output): void { echo $output . PHP_EOL; } function normalize_property_keys(array $props, ?array $matchers = []): array { $normalized = []; foreach ($props as $key => $value) { $matched_key = $matchers[$key] ?? null; if ($matched_key) { $normalized[$matched_key] = $value; } else { $norm_key = preg_replace('/[-\s]+/', '', $key); $normalized[$norm_key] = $value; } } return $normalized; } $keys = [ 'align' => 'alignment', 'col' => 'color', 'colour' => 'color', ]; $tests = [ 'align' => 1, 'col' => 2, 'test-key' => 3, 'test_new_key' => 4, ]; print_line("Original Array"); print_r($tests); print_line(""); print_line("Normalized Array"); print_r(normalize_property_keys($tests, $keys));

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.30.0080.01016.98
8.5.20.0170.00616.78
8.5.10.0310.00916.94
8.5.00.0330.00616.64
8.4.180.0250.00719.74
8.4.170.0150.00419.91
8.4.160.0170.00919.84
8.4.150.0240.00519.86
8.4.140.0190.00717.96
8.4.130.0180.00717.89
8.4.120.0410.00818.11
8.4.110.0320.00718.02
8.4.100.0310.01117.90
8.4.90.0270.00917.90
8.4.80.0310.00618.02
8.4.70.0370.00818.03
8.4.60.0230.00617.70
8.4.50.0240.00417.92
8.4.40.0200.00317.73
8.4.30.0220.00517.41
8.4.20.0180.00417.84
8.4.10.0210.00117.79
8.3.300.0190.00718.50
8.3.290.0230.00918.61
8.3.280.0150.00518.35
8.3.270.0160.00416.75
8.3.260.0150.00516.78
8.3.250.0210.00316.64
8.3.240.0200.00516.79
8.3.230.0370.00616.71
8.3.220.0360.00816.67
8.3.210.0380.00516.73
8.3.200.0270.00616.77
8.3.190.0190.00716.80
8.3.180.0240.00416.76
8.3.170.0260.00616.52
8.3.160.0280.01016.58
8.3.150.0290.00816.84
8.3.140.0280.00416.80
8.3.130.0220.00616.98
8.3.120.0190.00216.68
8.3.110.0240.00516.62
8.3.100.0240.00516.68
8.3.90.0190.00616.75
8.3.80.0220.00316.98
8.3.70.0230.00416.91
8.3.60.0180.00316.62
8.3.50.0180.00516.52
8.3.40.0150.00718.05
8.3.30.0140.00318.07
8.3.20.0170.00418.09
8.3.10.0150.00618.16
8.3.00.0200.00618.09

preferences:
49.81 ms | 711 KiB | 5 Q