3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ //... 'name' => ['value' => 'Raj KB'], 'street' => ['value' => 'Street ABC'], 'city' => ['value' => 'Dubai'], 'country_id' => ['value' => 'UAE'], 'region' => ['value' => 'DXB'], 'region_id' => ['value' => 11], 'zip_code' => ['value' => 12345], 'city_id' => ['value' => 22], //... ]; $ordered_keys = ['country_id', 'region', 'region_id', 'city', 'city_id']; $flag = true; $result = []; foreach ($array as $k=>$v) { if ($flag && in_array($k, $ordered_keys)) { $flag = false; foreach ($ordered_keys as $key) { $result[$key] = $array[$key]; } } else { $result[$k] = $array[$k]; } } print_r($result);

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.0120.00617.55
8.5.20.0100.00820.25
8.5.10.0130.00516.67
8.5.00.0100.01120.20
8.4.180.0080.01419.77
8.4.170.0120.01320.59
8.4.160.0150.00722.37
8.4.150.0020.00114.05
8.4.140.0120.00917.94
8.4.130.0120.00917.61
8.4.120.0160.00420.64
8.4.110.0040.00419.03
8.4.100.0130.00617.90
8.4.90.0100.00920.45
8.4.80.0120.00818.61
8.4.70.0050.00318.98
8.4.60.0040.00418.77
8.4.50.0140.00618.84
8.4.40.0130.00617.69
8.4.30.0040.00418.78
8.4.20.0120.00819.72
8.4.10.0090.00919.19
8.3.300.0120.00920.68
8.3.290.0130.00720.71
8.3.280.0120.00818.29
8.3.270.0080.00816.43
8.3.260.0040.00516.63
8.3.250.0140.00518.91
8.3.240.0030.00416.55
8.3.230.0070.00616.62
8.3.220.0100.00219.07
8.3.210.0120.00816.76
8.3.200.0030.00616.45
8.3.190.0080.00716.51
8.3.180.0130.00616.35
8.3.170.0090.00917.07
8.3.160.0110.00818.36
8.3.150.0030.00720.63
8.3.140.0000.00818.82
8.3.130.0120.00318.26
8.3.120.0060.00318.83
8.3.110.0080.00320.94
8.3.100.0070.00324.06
8.3.90.0110.00326.77
8.3.80.0090.00019.36
8.3.70.0120.00316.58
8.3.60.0000.01616.38
8.3.50.0130.00423.67
8.3.40.0060.00919.04
8.3.30.0040.01118.59
8.3.20.0070.00024.18
8.3.10.0000.00824.66
8.3.00.0070.00026.16
8.2.300.0100.00922.25
8.2.290.0110.00816.54
8.2.280.0100.00918.75
8.2.270.0120.00617.20
8.2.260.0000.00816.65
8.2.250.0080.00016.60
8.2.240.0070.00316.92
8.2.230.0050.00522.58
8.2.220.0140.00037.54
8.2.210.0050.00326.77
8.2.200.0090.00318.88
8.2.190.0070.00716.58
8.2.180.0070.01325.92
8.2.170.0040.01118.88
8.2.160.0030.01022.96
8.2.150.0050.00325.66
8.2.140.0000.00724.66
8.2.130.0080.00026.16
8.2.120.0070.00021.04
8.2.110.0060.00319.25
8.2.100.0080.00417.72
8.2.90.0050.00318.03
8.2.80.0030.00617.97
8.2.70.0060.00318.05
8.2.60.0000.00917.97
8.2.50.0040.00418.10
8.2.40.0030.00621.23
8.2.30.0030.00719.13
8.2.20.0040.00418.13
8.2.10.0040.00419.13
8.2.00.0070.00019.38
8.1.340.0120.00819.79
8.1.330.0040.01416.76
8.1.320.0080.01117.77
8.1.310.0170.00016.61
8.1.300.0110.00016.57
8.1.290.0080.00330.84
8.1.280.0150.00025.92
8.1.270.0040.00423.99
8.1.260.0050.00326.35
8.1.250.0000.00728.09
8.1.240.0060.00321.37
8.1.230.0060.00622.66
8.1.220.0050.00517.74
8.1.210.0050.00318.77
8.1.200.0040.00417.35
8.1.190.0080.00017.22
8.1.180.0080.00018.10
8.1.170.0030.00518.45
8.1.160.0040.00418.93
8.1.150.0040.00418.77
8.1.140.0000.00818.93
8.1.130.0000.00720.15
8.1.120.0040.00417.46
8.1.110.0000.00817.48
8.1.100.0040.00417.53
8.1.90.0000.00717.41
8.1.80.0030.00517.37
8.1.70.0000.00717.48
8.1.60.0040.00417.64
8.1.50.0000.00817.51
8.1.40.0000.00817.53
8.1.30.0000.00817.59
8.1.20.0060.00317.64
8.1.10.0030.00517.40
8.1.00.0080.00017.43
8.0.300.0070.00320.04
8.0.290.0000.00816.63
8.0.280.0040.00418.41
8.0.270.0030.00618.45
8.0.260.0000.00618.45
8.0.250.0030.00316.92
8.0.240.0000.00616.86
8.0.230.0030.00316.89
8.0.220.0030.00316.89
8.0.210.0000.00716.77
8.0.200.0050.00216.83
8.0.190.0040.00416.80
8.0.180.0040.00416.98
8.0.170.0060.00516.84
8.0.160.0050.00316.97
8.0.150.0000.00716.82
8.0.140.0000.00816.83
8.0.130.0000.00613.36
8.0.120.0000.00916.73
8.0.110.0040.00416.90
8.0.100.0040.00416.93
8.0.90.0030.00616.96
8.0.80.0150.00316.85
8.0.70.0000.00716.80
8.0.60.0000.00716.77
8.0.50.0040.00416.89
8.0.30.0100.00716.81
8.0.20.0100.01016.91
8.0.10.0040.00416.97
8.0.00.0140.00416.81
7.4.330.0050.00015.55
7.4.320.0000.00616.66
7.4.300.0000.00616.50
7.4.290.0040.00416.43
7.4.280.0040.00416.54
7.4.270.0040.00416.38
7.4.260.0030.00313.34
7.4.250.0040.00416.45
7.4.240.0000.00716.61
7.4.230.0000.00716.44
7.4.220.0030.00316.48
7.4.210.0090.00616.60
7.4.200.0070.00016.66
7.4.130.0120.00616.42
7.4.120.0090.01316.64
7.4.110.0130.01016.53
7.4.100.0140.01016.65
7.4.90.0170.00016.49
7.4.80.0100.01319.39
7.4.70.0070.01016.51
7.4.60.0140.01016.52
7.4.50.0120.01216.54
7.4.40.0180.00316.50
7.4.30.0080.01116.51
7.4.20.0100.01516.27
7.4.10.0200.00416.42
7.4.00.0060.01616.21
7.3.330.0000.00616.37
7.3.320.0000.00613.16
7.3.310.0030.00316.41
7.3.300.0040.00416.33
7.3.290.0090.00616.35
7.3.280.0130.01016.26
7.3.260.0110.01216.38
7.3.240.0080.01016.58
7.3.230.0220.00016.66
7.3.210.0110.00416.49
7.3.200.0000.01616.30
7.3.190.0100.00716.58
7.3.180.0070.01416.40
7.3.170.0050.01216.28
7.3.160.0090.00416.29
7.3.150.0080.00416.47
7.3.140.0080.01516.64
7.3.130.0030.02116.41
7.3.120.0160.00316.58
7.3.110.0140.00616.22
7.3.100.0080.01216.57
7.3.90.0040.01416.58
7.3.80.0130.00616.46
7.3.70.0060.01116.45
7.3.60.0120.00616.32
7.3.50.0170.00016.53
7.3.40.0150.00916.05
7.3.30.0130.00916.29
7.3.20.0060.01316.03
7.3.10.0180.00616.02
7.3.00.0140.00716.04
7.2.330.0140.00416.61
7.2.310.0090.01116.39
7.2.300.0050.01316.64
7.2.290.0100.01316.66
7.2.280.0140.00516.67
7.2.270.0060.01316.70
7.2.260.0130.00616.62
7.2.250.0160.00516.34
7.2.240.0110.00716.69
7.2.230.0090.00916.69
7.2.220.0100.01016.84
7.2.210.0090.00916.51
7.2.200.0060.01316.69
7.2.190.0120.00616.52
7.2.180.0150.00816.30
7.2.170.0030.01416.00
7.2.160.0130.01016.47
7.2.150.0110.01316.18
7.2.140.0100.01016.64
7.2.130.0090.01616.43
7.2.120.0120.01116.19
7.2.110.0120.00616.34
7.2.100.0150.00716.34
7.2.90.0090.01516.46
7.2.80.0110.01116.70
7.2.70.0170.00616.52
7.2.60.0240.00916.56
7.2.50.0130.00816.42
7.2.40.0490.00916.33
7.2.30.0190.00416.38
7.2.20.0130.01016.64
7.2.10.0150.00416.48
7.2.00.0100.01016.42

preferences:
164.21 ms | 403 KiB | 5 Q