3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cityID = '2'; $oldCityFound = false; $newCityFound = false; $arr = [ '1' => ['ID'=>'1', 'NAME'=>'Moscow', 'UF_DEFAULT'=>'1', 'UF_CITY_CORD'=>'55.76, 37.64'], '2' => ['ID'=>'2', 'NAME'=>'Tver', 'UF_DEFAULT'=>'0', 'UF_CITY_CORD'=>'55.76, 37.64'], '3' => ['ID'=>'3', 'NAME'=>'Nahodka', 'UF_DEFAULT'=>'0', 'UF_CITY_CORD'=>'55.76, 37.64'], '4' => ['ID'=>'4', 'NAME'=>'Omsk', 'UF_DEFAULT'=>'0', 'UF_CITY_CORD'=>'55.76, 37.64'], ]; foreach ($arr as &$row) { if ($row['ID'] == $cityID) { if ($row['UF_DEFAULT'] == 1) { break; // nothing to change } $row['UF_DEFAULT'] = 1; $newCityFound = true; } elseif ($row['UF_DEFAULT'] == 1) { $row['UF_DEFAULT'] = 0; $oldCityFound = true; } if ($newCityFound && $oldCityFound) { break; // both jobs done ...efficiently } } unset($row); // best practice var_export($arr);

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.10.0120.00518.23
8.5.00.0120.00919.89
8.4.150.0020.00114.05
8.4.140.0150.00617.44
8.4.130.0070.00217.55
8.4.120.0110.00922.44
8.4.110.0150.00518.80
8.4.100.0100.01117.52
8.4.90.0140.00818.10
8.4.80.0060.00317.82
8.4.70.0100.01017.68
8.4.60.0090.01418.65
8.4.50.0110.00920.61
8.4.40.0040.00419.32
8.4.30.0170.00722.70
8.4.20.0100.01018.86
8.4.10.0090.00019.66
8.3.280.0100.01218.21
8.3.270.0090.01016.74
8.3.260.0120.00716.74
8.3.250.0150.00519.05
8.3.240.0110.01016.28
8.3.230.0110.00916.45
8.3.220.0110.00819.08
8.3.210.0120.00718.60
8.3.200.0050.00416.65
8.3.190.0020.00619.02
8.3.180.0080.00818.26
8.3.170.0160.00417.31
8.3.160.0120.00622.59
8.3.150.0060.01216.44
8.3.140.0000.00816.94
8.3.130.0030.00616.62
8.3.120.0120.00619.10
8.3.110.0040.00416.75
8.3.100.0030.00624.06
8.3.90.0080.01126.77
8.3.80.0030.00616.50
8.3.70.0070.01116.58
8.3.60.0120.00618.14
8.3.50.0110.00722.00
8.3.40.0060.00918.79
8.3.30.0040.01118.67
8.3.20.0090.00621.87
8.3.10.0040.00420.16
8.3.00.0040.00423.39
8.2.290.0130.00620.48
8.2.280.0100.00818.59
8.2.270.0080.00017.47
8.2.260.0180.00018.38
8.2.250.0030.00616.81
8.2.240.0060.00319.16
8.2.230.0030.00520.94
8.2.220.0130.00737.54
8.2.210.0160.00326.77
8.2.200.0030.00616.75
8.2.190.0110.00416.63
8.2.180.0140.00725.92
8.2.170.0110.00419.14
8.2.160.0070.00722.96
8.2.150.0040.00424.18
8.2.140.0070.00024.66
8.2.130.0070.00026.16
8.2.120.0040.01119.79
8.2.110.0030.00620.53
8.2.100.0080.00417.78
8.2.90.0030.00517.63
8.2.80.0040.00418.89
8.2.70.0040.00417.63
8.2.60.0000.00817.77
8.2.50.0040.00418.07
8.2.40.0030.00518.29
8.2.30.0060.00318.12
8.2.20.0030.00618.18
8.2.10.0040.00419.34
8.2.00.0040.00419.31
8.1.330.0060.00316.66
8.1.320.0090.00616.16
8.1.310.0050.00218.61
8.1.300.0060.00317.66
8.1.290.0030.00618.88
8.1.280.0060.00925.92
8.1.270.0060.00324.01
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0030.00722.14
8.1.230.0000.01222.11
8.1.220.0030.00617.79
8.1.210.0050.00518.77
8.1.200.0050.00517.35
8.1.190.0030.00517.35
8.1.180.0030.00618.10
8.1.170.0040.00418.53
8.1.160.0050.00319.01
8.1.150.0000.00718.97
8.1.140.0000.00718.91
8.1.130.0000.00720.07
8.1.120.0050.00317.50
8.1.110.0060.00317.52
8.1.100.0040.00417.44
8.1.90.0000.00817.36
8.1.80.0030.00617.49
8.1.70.0000.00717.51
8.1.60.0000.00817.48
8.1.50.0060.00317.50
8.1.40.0030.00617.54
8.1.30.0000.00817.61
8.1.20.0030.00617.55
8.1.10.0060.00317.59
8.1.00.0040.00417.53
8.0.300.0070.00018.77
8.0.290.0000.00816.75
8.0.280.0050.00218.51
8.0.270.0070.00016.83
8.0.260.0040.00420.15
8.0.250.0030.00316.97
8.0.240.0040.00416.94
8.0.230.0000.00816.98
8.0.220.0040.00416.90
8.0.210.0070.00016.89
8.0.200.0030.00316.98
8.0.190.0050.00317.00
8.0.180.0040.00416.89
8.0.170.0040.00816.93
8.0.160.0040.00716.92
8.0.150.0070.00016.85
8.0.140.0030.00316.84
8.0.130.0060.00013.35
8.0.120.0030.00716.73
8.0.110.0040.00416.89
8.0.100.0050.00217.03
8.0.90.0060.00316.97
8.0.80.0090.00616.91
8.0.70.0000.00716.97
8.0.60.0070.00016.79
8.0.50.0000.00716.95
8.0.30.0130.00217.17
8.0.20.0120.00617.03
8.0.10.0050.00317.07
8.0.00.0130.00916.77
7.4.330.0030.00315.55
7.4.320.0030.00316.60
7.4.300.0040.00416.58
7.4.290.0050.00216.52
7.4.280.0040.00416.56
7.4.270.0030.00516.58
7.4.260.0070.00016.54
7.4.250.0050.00216.59
7.4.240.0070.00016.54
7.4.230.0000.00716.52
7.4.220.0040.00416.27
7.4.210.0080.00716.52
7.4.200.0030.00316.55
7.4.140.0060.01617.86
7.4.130.0160.00416.45
7.4.120.0160.00316.63
7.4.110.0040.01416.48
7.4.100.0070.01016.42
7.4.90.0040.01316.67
7.4.80.0060.01219.39
7.4.70.0100.00716.39
7.4.60.0080.00816.42
7.4.50.0030.01016.61
7.4.40.0110.00816.25
7.4.00.0030.01114.79
7.3.330.0000.00513.24
7.3.320.0060.00013.04
7.3.310.0030.00316.19
7.3.300.0030.00316.36
7.3.290.0030.00316.36
7.3.280.0100.00916.26
7.3.260.0100.00916.44
7.3.240.0080.00916.48
7.3.230.0190.00016.30
7.3.210.0060.01116.61
7.3.200.0080.00816.62
7.3.190.0060.00916.25
7.3.180.0120.00316.65
7.3.170.0250.01916.32
7.3.160.0060.00916.38
7.3.120.0060.01314.95
7.3.110.0110.00714.60
7.3.100.0110.00715.13
7.3.90.0140.00714.93
7.3.80.0080.00614.67
7.3.70.0070.01014.70
7.3.60.0080.01014.91
7.3.50.0030.01014.81
7.3.40.0070.00814.75
7.3.30.0040.00914.91
7.3.20.0070.00815.69
7.3.10.0090.00515.75
7.3.00.0090.00915.84
7.2.330.0070.01016.70
7.2.320.0070.01016.76
7.2.310.0160.00616.74
7.2.300.0140.00416.63
7.2.290.0110.00716.61
7.2.250.0060.00914.93
7.2.240.0030.01415.15
7.2.230.0030.01314.96
7.2.220.0070.00715.24
7.2.210.0120.00314.80
7.2.200.0060.00615.04
7.2.190.0110.00915.03
7.2.180.0110.00315.04
7.2.170.0070.01015.13
7.2.160.0130.00015.29
7.2.150.0090.00915.16
7.2.140.0100.00315.12
7.2.130.0100.01015.13
7.2.120.0150.00015.29
7.2.110.0150.00314.79
7.2.100.0140.01714.98
7.2.90.0110.00415.23
7.2.80.0140.00015.08
7.2.70.0070.00715.31
7.2.60.0100.00315.35
7.2.50.0180.01215.08
7.2.40.0220.00315.18
7.2.30.0090.01515.16
7.2.20.0890.01015.11
7.2.10.0180.00915.08
7.2.00.0130.01315.13
7.1.330.0030.01015.95
7.1.320.0090.00615.62
7.1.310.0000.00915.93
7.1.300.0110.00614.78
7.1.290.0060.00814.96
7.1.280.0060.01214.88
7.1.270.0050.00814.95
7.1.260.0080.00614.95
7.1.250.0150.01014.26

preferences:
36.81 ms | 403 KiB | 5 Q