3v4l.org

run code in 300+ PHP versions simultaneously
<?php function filterTagsByTypes(array $tags, array $types, $count = 1) { $returnTags = []; sort($types); //Sort from low to high => high priority to low priority usort($tags, function($a, $b) { if ($a->type == $b->type) { return 0; } return $a->type > $b->type ? 1 : -1; }); //Sort tags array from low type to high type. foreach ($types as $type) { foreach ($tags as $tag) { //In this case, since both arrays are sorted, the priority //you are looking for will not arrive. if ($tag->type > $type) { break; //So break out and continue to the next type. } if ($tag->type == $type) { $returnTags[] = $tag; } if (count($returnTags) >= $count) { //End it now! return $returnTags; } } } } // Usage: class Tag { private $type; function __construct($type) { $this->type = $type; } } $tags = [ new Tag(50), new Tag(1), new Tag(25) ]; $types = [1, 50]; var_dump(filterTagsByTypes($tags, $types));

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.3.60.0150.00618.65
8.3.50.0100.01022.82
8.3.40.0070.00719.02
8.3.30.0120.00419.08
8.3.20.0090.00620.20
8.3.10.0090.00923.66
8.3.00.0000.01517.75
8.2.180.0180.00316.88
8.2.170.0110.00722.96
8.2.160.0130.00720.34
8.2.150.0170.00324.18
8.2.140.0070.01024.66
8.2.130.0070.00026.16
8.2.120.0000.00720.90
8.2.110.0040.00419.07
8.2.100.0060.00619.76
8.2.90.0000.00819.01
8.2.80.0080.00017.97
8.2.70.0080.00017.63
8.2.60.0090.00317.93
8.2.50.0060.00318.07
8.2.40.0000.01118.09
8.2.30.0070.00018.14
8.2.20.0000.00817.75
8.2.10.0050.00218.13
8.2.00.0000.00717.87
8.1.280.0070.00725.92
8.1.270.0120.00323.73
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0070.00319.29
8.1.230.0100.00319.00
8.1.220.0040.00417.79
8.1.210.0030.00618.77
8.1.200.0040.00717.35
8.1.190.0040.00417.35
8.1.180.0060.00318.10
8.1.170.0080.00018.65
8.1.160.0000.00721.96
8.1.150.0000.00818.96
8.1.140.0000.00717.39
8.1.130.0000.00717.73
8.1.120.0030.00517.55
8.1.110.0050.00317.52
8.1.100.0000.00717.37
8.1.90.0040.00417.52
8.1.80.0040.00417.55
8.1.70.0000.00717.46
8.1.60.0060.00317.64
8.1.50.0030.00517.57
8.1.40.0030.00517.50
8.1.30.0000.00817.73
8.1.20.0000.00817.66
8.1.10.0070.00017.51
8.1.00.0000.00717.39
8.0.300.0000.00718.77
8.0.290.0040.00416.75
8.0.280.0000.00718.46
8.0.270.0050.00217.18
8.0.260.0000.00717.28
8.0.250.0000.00717.01
8.0.240.0030.00317.06
8.0.230.0000.00716.99
8.0.220.0040.00416.96
8.0.210.0070.00016.86
8.0.200.0000.00617.05
8.0.190.0030.00917.05
8.0.180.0000.00816.97
8.0.170.0070.00017.01
8.0.160.0030.00516.87
8.0.150.0030.00316.94
8.0.140.0000.00716.91
8.0.130.0000.00913.34
8.0.120.0050.00216.89
8.0.110.0000.00716.87
8.0.100.0030.00516.86
8.0.90.0000.00716.83
8.0.80.0070.01416.93
8.0.70.0000.00716.92
8.0.60.0000.00717.02
8.0.50.0000.00716.84
8.0.30.0100.01117.31
8.0.20.0100.01117.40
8.0.10.0040.00416.88
8.0.00.0110.00916.79
7.4.330.0000.00615.03
7.4.320.0000.00616.66
7.4.300.0000.00716.57
7.4.290.0050.00216.62
7.4.280.0020.00516.52
7.4.270.0040.00416.57
7.4.260.0100.00216.49
7.4.250.0000.00716.60
7.4.240.0020.00516.54
7.4.230.0030.00316.68
7.4.220.0150.00816.61
7.4.210.0060.01316.58
7.4.200.0070.00016.51
7.4.160.0060.01016.43
7.4.150.0140.01117.40
7.4.140.0110.01017.86
7.4.130.0030.01816.51
7.4.120.0080.00916.50
7.4.110.0030.01316.43
7.4.100.0100.00716.48
7.4.90.0110.00716.66
7.4.80.0130.00419.39
7.4.70.0000.01716.54
7.4.60.0060.01316.64
7.4.50.0050.00316.53
7.4.40.0100.00716.37
7.4.30.0080.00816.74
7.4.00.0050.00514.89
7.3.330.0000.00513.25
7.3.320.0050.00013.22
7.3.310.0070.00016.37
7.3.300.0070.00016.38
7.3.290.0070.00716.34
7.3.280.0040.01316.42
7.3.270.0170.00017.40
7.3.260.0100.01016.40
7.3.250.0130.00616.38
7.3.240.0140.00316.59
7.3.230.0080.00816.57
7.3.210.0090.00916.23
7.3.200.0120.00319.39
7.3.190.0030.01216.54
7.3.180.0100.00616.65
7.3.170.0060.00916.55
7.3.160.0130.00316.50
7.2.330.0160.00716.70
7.2.320.0120.00516.71
7.2.310.0030.01316.72
7.2.300.0140.00316.63
7.2.290.0070.01016.52
7.2.60.0060.00616.94
7.2.00.0000.01219.35
7.1.200.0130.00015.46
7.1.100.0350.00618.03
7.1.70.0130.00017.18
7.1.60.0130.00417.39
7.1.50.0000.01617.07
7.1.40.0120.00916.59
7.1.30.0090.00916.68
7.1.20.0060.01316.75
7.1.10.0110.00616.58
7.1.00.0030.01416.53
7.0.200.0110.00416.84
7.0.190.0070.00716.76
7.0.180.0080.01516.15
7.0.170.0060.00616.39
7.0.160.0120.00816.14
7.0.150.0110.00416.05
7.0.140.0100.00316.22
7.0.130.0060.00916.73
7.0.120.0140.00316.63
7.0.110.0140.00316.35
7.0.100.0030.01016.48
7.0.90.0060.00916.38
7.0.80.0090.00416.41
7.0.70.0080.00516.18
7.0.60.0090.00916.35
7.0.50.0050.01016.31
7.0.40.0050.01015.60
7.0.30.0070.00515.60
7.0.20.0040.00815.60
7.0.10.0000.01215.60
7.0.00.0000.01115.60
5.6.300.0070.04320.96
5.6.290.0100.08321.00
5.6.280.0000.05020.80
5.6.270.0110.03921.09
5.6.260.0070.04920.91
5.6.250.0060.04320.98
5.6.240.0040.07420.89
5.6.230.0070.07020.84
5.6.220.0060.05720.82
5.6.210.0120.04721.06
5.6.200.0070.04420.84
5.6.190.0060.04520.87
5.6.180.0000.04820.86
5.6.170.0060.04020.97
5.6.160.0120.05520.84
5.6.150.0070.06820.94
5.6.140.0100.04220.98
5.6.130.0030.05120.92
5.6.120.0140.05821.00
5.6.110.0070.08020.94
5.6.100.0040.04620.93
5.6.90.0070.05420.82
5.6.80.0070.03920.41
5.6.70.0100.04120.37
5.6.60.0090.04420.37
5.6.50.0110.04320.13
5.6.40.0030.04820.39
5.6.30.0090.04220.29
5.6.20.0060.04520.39
5.6.10.0100.03620.19
5.6.00.0030.04420.17
5.5.380.0030.08317.41
5.5.370.0090.03817.57
5.5.360.0090.06517.61
5.5.350.0030.04317.53
5.5.340.0070.04118.09
5.5.330.0030.04117.75
5.5.320.0040.03918.07
5.5.310.0030.04518.00
5.5.300.0070.04118.11
5.5.290.0030.04318.04
5.5.280.0090.03718.00
5.5.270.0070.04018.03
5.5.260.0100.03518.05
5.5.250.0030.07017.52
5.5.240.0090.03617.57
5.5.230.0090.04117.56
5.5.220.0030.07417.39
5.5.210.0070.03917.43
5.5.200.0070.03717.49
5.5.190.0000.04917.43
5.5.180.0090.03917.10
5.5.160.0070.03917.53
5.5.150.0120.03717.42
5.5.140.0000.04417.37
5.5.130.0040.04617.52
5.5.120.0070.03717.21
5.5.110.0070.04317.43
5.5.100.0000.04617.29
5.5.90.0090.03417.32
5.5.80.0090.03317.25
5.5.70.0070.03717.29
5.5.60.0100.03317.24
5.5.50.0030.04717.28
5.5.40.0030.03817.34
5.5.30.0190.02616.98
5.5.20.0060.04117.29
5.5.10.0030.03917.31
5.5.00.0000.04117.27
5.4.450.0040.05119.38
5.4.440.0070.05919.32
5.4.430.0030.03919.45
5.4.420.0070.03619.30
5.4.410.0000.04019.26
5.4.400.0070.03419.13
5.4.390.0030.06218.82
5.4.380.0060.03519.13
5.4.370.0030.05219.11
5.4.360.0040.04419.18
5.4.350.0060.03919.21
5.4.340.0030.04618.95
5.4.320.0030.04218.89
5.4.310.0110.03319.00
5.4.300.0060.03918.96
5.4.290.0000.04718.96
5.4.280.0030.04118.93
5.4.270.0030.03818.96
5.4.260.0000.04318.95
5.4.250.0030.04519.17
5.4.240.0130.03519.11
5.4.230.0030.04518.96
5.4.220.0040.03918.96
5.4.210.0090.03118.96
5.4.200.0000.04319.17
5.4.190.0000.04418.93
5.4.180.0030.04018.92
5.4.170.0030.03819.19
5.4.160.0100.03419.16
5.4.150.0030.04119.01
5.4.140.0190.03816.73
5.4.130.0000.04616.46
5.4.120.0030.04516.77
5.4.110.0060.04116.48
5.4.100.0060.03416.75
5.4.90.0030.04216.66
5.4.80.0060.03216.60
5.4.70.0060.06316.73
5.4.60.0000.05516.70
5.4.50.0030.03416.67
5.4.40.0040.03516.70
5.4.30.0000.04016.44
5.4.20.0000.04016.42
5.4.10.0060.03216.71
5.4.00.0000.04316.07
5.3.290.0080.04115.60
5.3.280.0090.03115.60
5.3.270.0030.04615.60
5.3.260.0100.04515.60
5.3.250.0260.04615.60
5.3.240.0000.04515.60
5.3.230.0040.03915.60
5.3.220.0060.03515.60
5.3.210.0060.03615.60
5.3.200.0030.04115.60
5.3.190.0100.03315.60
5.3.180.0030.03615.60
5.3.170.0060.03315.60
5.3.160.0030.03615.60
5.3.150.0030.04815.60
5.3.140.0040.03915.60
5.3.130.0100.03915.60
5.3.120.0030.04715.60
5.3.110.0040.03615.60
5.3.100.0000.04215.60
5.3.90.0310.02415.60
5.3.80.0070.03915.60
5.3.70.0000.04215.60
5.3.60.0030.03815.60
5.3.50.0070.03315.60
5.3.40.0000.04015.60
5.3.30.0090.03915.60
5.3.20.0040.03315.60
5.3.10.0130.03015.60
5.3.00.0000.06415.60
5.2.170.0070.02915.60
5.2.160.0030.02815.60
5.2.150.0110.03215.60
5.2.140.0000.03215.60
5.2.130.0000.03715.60
5.2.120.0060.02715.60
5.2.110.0140.03115.60
5.2.100.0060.03215.60
5.2.90.0250.03915.60
5.2.80.0000.03115.60
5.2.70.0060.02715.60
5.2.60.0090.02715.60
5.2.50.0060.05015.60
5.2.40.0060.02515.60
5.2.30.0060.02515.60
5.2.20.0060.02715.60
5.2.10.0090.04015.60
5.2.00.0040.02915.60
5.1.60.0040.02315.60
5.1.50.0000.03315.60
5.1.40.0040.02515.60
5.1.30.0030.02615.60
5.1.20.0000.02915.60
5.1.10.0000.03215.60
5.1.00.0000.03415.60
5.0.50.0000.02215.60
5.0.40.0000.02315.60
5.0.30.0030.03215.60
5.0.20.0060.01815.60
5.0.10.0070.03015.60
5.0.00.0030.03215.60
4.4.90.0060.02115.60
4.4.80.0060.01215.60
4.4.70.0040.01415.60
4.4.60.0040.01315.60
4.4.50.0000.03415.60
4.4.40.0030.02515.60
4.4.30.0030.01415.60
4.4.20.0040.01815.60
4.4.10.0000.01815.60
4.4.00.0000.02615.60
4.3.110.0040.01515.60
4.3.100.0000.01815.60
4.3.90.0000.03215.60
4.3.80.0040.02115.60
4.3.70.0060.00915.60
4.3.60.0000.01615.60
4.3.50.0000.03815.60
4.3.40.0030.03715.60
4.3.30.0000.01815.60
4.3.20.0000.01715.60
4.3.10.0030.01515.60
4.3.00.0000.02215.60

preferences:
42.4 ms | 401 KiB | 5 Q