3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* span :: (a -> Bool) -> [a] -> ([a],[a]) span _ xs@[] = (xs, xs) span p xs@(x:xs') | p x = let (ys,zs) = span p xs' in (x:ys,zs) | otherwise = ([],xs) */ function span($p, $xs) { if (empty($xs)) { return [[], []]; } $xs_ = $xs; $x = array_shift($x); if ($p($x)) { list($ys, $zs) = span($p, $xs_); return [array_unshift($ys, $x), $zs]; } return [[], $xs]; } /* groupBy :: (a -> a -> Bool) -> [a] -> [[a]] groupBy _ [] = [] groupBy eq (x:xs) = (x:ys) : groupBy eq zs where (ys,zs) = span (eq x) xs */ function array_group(callable $eq, array $xs) { if (empty($xs)) { return []; } $x = array_shift($xs); list($ys, $zs) = span($eq($x), $xs); } function it($m,$p){echo ($p?'✔︎':'✘')." It $m\n"; if(!$p){$GLOBALS['f']=1;}}function done(){if(@$GLOBALS['f'])die(1);} it('spans elements', span(function ($x) { return $x < 2; }, [1, 2, 3]) === [[1, 2], [3]]);

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.00416.63
8.3.50.0130.00722.04
8.3.40.0040.01118.84
8.3.30.0100.00319.05
8.3.20.0070.00020.29
8.3.10.0080.00023.56
8.3.00.0050.00319.26
8.2.180.0040.01216.87
8.2.170.0000.01522.96
8.2.160.0070.00720.34
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0000.00726.16
8.2.120.0040.00422.06
8.2.110.0090.00020.53
8.2.100.0080.00418.03
8.2.90.0040.00419.27
8.2.80.0050.00317.97
8.2.70.0050.00517.50
8.2.60.0030.00617.92
8.2.50.0090.00018.07
8.2.40.0000.00919.93
8.2.30.0030.00618.08
8.2.20.0060.00317.81
8.2.10.0050.00218.13
8.2.00.0050.00317.89
8.1.280.0120.00925.92
8.1.270.0030.00522.15
8.1.260.0000.00726.35
8.1.250.0050.00328.09
8.1.240.0100.00022.10
8.1.230.0080.00417.64
8.1.220.0000.00817.74
8.1.210.0060.00318.77
8.1.200.0030.00617.23
8.1.190.0000.00817.48
8.1.180.0060.00318.10
8.1.170.0040.00418.57
8.1.160.0040.00421.99
8.1.150.0000.00719.01
8.1.140.0000.00817.45
8.1.130.0000.00717.78
8.1.120.0000.00717.50
8.1.110.0040.00417.47
8.1.100.0040.00417.49
8.1.90.0000.00717.46
8.1.80.0050.00317.38
8.1.70.0030.00317.41
8.1.60.0040.00417.62
8.1.50.0050.00317.57
8.1.40.0000.00817.48
8.1.30.0040.00417.71
8.1.20.0000.00717.67
8.1.10.0080.00017.48
8.1.00.0040.00417.48
8.0.300.0040.00418.77
8.0.290.0060.00316.75
8.0.280.0030.00318.41
8.0.270.0000.00817.12
8.0.260.0000.00817.26
8.0.250.0040.00416.97
8.0.240.0040.00416.96
8.0.230.0070.00016.91
8.0.220.0060.00316.81
8.0.210.0000.00716.82
8.0.200.0040.00417.03
8.0.190.0030.00917.07
8.0.180.0050.00317.01
8.0.170.0080.00016.95
8.0.160.0000.00817.08
8.0.150.0040.00416.92
8.0.140.0040.00416.89
8.0.130.0000.00513.36
8.0.120.0000.00816.86
8.0.110.0040.00416.94
8.0.100.0000.00716.80
8.0.90.0040.00416.94
8.0.80.0060.01516.91
8.0.70.0000.00717.04
8.0.60.0040.00416.91
8.0.50.0040.00416.99
8.0.30.0170.00617.14
8.0.20.0100.00917.40
8.0.10.0040.00416.96
8.0.00.0080.01016.92
7.4.330.0060.00015.00
7.4.320.0000.00616.58
7.4.300.0070.00016.64
7.4.290.0030.00316.53
7.4.280.0030.00616.63
7.4.270.0080.00016.54
7.4.260.0030.00316.54
7.4.250.0080.00016.58
7.4.240.0020.00516.58
7.4.230.0070.00016.70
7.4.220.0080.01216.57
7.4.210.0060.00916.48
7.4.200.0040.00416.44
7.4.160.0080.01116.69
7.4.150.0110.01117.40
7.4.140.0090.01117.86
7.4.130.0120.00816.55
7.4.120.0140.00816.62
7.4.110.0130.00716.64
7.4.100.0120.00916.46
7.4.90.0120.00816.59
7.4.80.0140.01019.39
7.4.70.0050.01916.48
7.4.60.0110.00816.66
7.4.50.0070.00016.73
7.4.40.0090.01216.56
7.4.30.0060.01316.50
7.4.00.0070.01015.13
7.3.330.0060.00013.60
7.3.320.0000.00713.47
7.3.310.0020.00516.46
7.3.300.0070.00016.46
7.3.290.0130.00316.43
7.3.280.0130.00416.43
7.3.270.0160.00517.40
7.3.260.0160.00516.52
7.3.250.0130.00516.47
7.3.240.0110.01216.64
7.3.230.0190.00616.48
7.3.210.0120.00816.48
7.3.200.0040.01816.30
7.3.190.0130.01016.43
7.3.180.0140.00316.56
7.3.170.0130.00716.59
7.3.160.0160.00616.75
7.2.330.0170.00316.54
7.2.320.0040.01616.82
7.2.310.0100.00716.44
7.2.300.0060.01216.67
7.2.290.0050.01516.91
7.2.60.0000.01516.97
7.2.00.0060.00619.28
7.1.200.0040.00715.72
7.1.100.0030.00918.09
7.1.70.0120.00417.05
7.1.60.0090.01219.11
7.1.50.0140.01017.09
7.1.00.0100.07322.24
7.0.200.0000.01116.86
7.0.140.0070.07322.09
7.0.60.0130.07020.02
7.0.50.0030.04017.97
7.0.40.0070.05319.96
7.0.30.0430.04319.85
7.0.20.0200.09019.95
7.0.10.0130.08019.97
7.0.00.0070.09019.97
5.6.280.0100.06721.34
5.6.210.0100.03720.80
5.6.200.0070.04718.32
5.6.190.0070.04020.70
5.6.180.0270.08321.13
5.6.170.1330.05320.68
5.6.160.0100.07320.64
5.6.150.0100.06318.47
5.6.140.0030.04018.46
5.6.130.0070.08718.43
5.6.120.0170.07021.11
5.6.110.0000.07721.33
5.6.100.0070.05721.31
5.6.90.0000.06021.21
5.6.80.0070.08720.85
5.5.350.0070.03720.72
5.5.340.0000.08718.31
5.5.330.0130.08020.49
5.5.320.0430.06320.47
5.5.310.0300.07320.59
5.5.300.0100.03718.32
5.5.290.0170.07718.36
5.5.280.0130.07721.28
5.5.270.0070.05721.07
5.5.260.0130.07721.27
5.5.250.0100.04321.03
5.5.240.0230.07020.46
5.4.450.0700.06019.78
5.4.440.0600.06319.67
5.4.430.0800.05319.76
5.4.420.0700.00019.76
5.4.410.0670.00019.58
5.4.400.0670.00019.48
5.4.390.0670.00019.28
5.4.380.0930.00019.33
5.4.370.0630.00019.48
5.4.360.0630.00019.34
5.4.350.0700.00019.41
5.4.340.0090.03412.31
5.4.320.0100.04212.80
5.4.310.0070.04212.80
5.4.300.0090.03912.80
5.4.290.0100.03612.79
5.4.280.0070.03712.69
5.4.270.0090.03512.69
5.4.260.0070.04012.69
5.4.250.0090.03912.69
5.4.240.0100.04412.69
5.4.230.0050.04112.69
5.4.220.0110.04112.69
5.4.210.0130.03312.69
5.4.200.0150.03812.69
5.4.190.0150.04712.68
5.4.180.0100.05112.68
5.4.170.0120.04812.69
5.4.160.0090.03412.68
5.4.150.0120.04012.68
5.4.140.0080.04212.36
5.4.130.0080.04112.35
5.4.120.0050.03912.31
5.4.110.0080.03512.31
5.4.100.0040.04012.31
5.4.90.0080.03712.30
5.4.80.0070.03712.30
5.4.70.0080.03412.30
5.4.60.0050.03712.30
5.4.50.0070.04112.30
5.4.40.0080.04412.29
5.4.30.0120.03612.29
5.4.20.0080.03512.29
5.4.10.0070.03812.29
5.4.00.0060.04011.77
5.3.290.0050.04112.80
5.3.280.0040.04112.71
5.3.270.0030.04212.72
5.3.260.0070.03912.72
5.3.250.0060.03912.72
5.3.240.0070.03712.72
5.3.230.0080.04312.71
5.3.220.0050.03812.68
5.3.210.0090.03712.68
5.3.200.0050.03912.68
5.3.190.0030.04312.68
5.3.180.0050.03812.68
5.3.170.0060.04212.67
5.3.160.0070.04812.67
5.3.150.0070.04712.67
5.3.140.0080.03512.66
5.3.130.0090.03712.66
5.3.120.0070.03812.66
5.3.110.0080.03712.66
5.3.100.0060.03812.13
5.3.90.0060.03812.11
5.3.80.0060.04512.09
5.3.70.0110.04112.09
5.3.60.0040.03812.08
5.3.50.0050.04712.02
5.3.40.0100.03312.02
5.3.30.0040.03711.98
5.3.20.0070.03411.76
5.3.10.0060.03411.74
5.3.00.0050.04211.71
5.2.170.0050.0309.21
5.2.160.0050.0299.21
5.2.150.0050.0309.21
5.2.140.0040.0329.21
5.2.130.0040.0319.17
5.2.120.0040.0319.17
5.2.110.0050.0329.18
5.2.100.0050.0289.18
5.2.90.0060.0309.18
5.2.80.0050.0359.18
5.2.70.0070.0309.17
5.2.60.0060.0309.13
5.2.50.0060.0339.09
5.2.40.0080.0389.07
5.2.30.0060.0369.05
5.2.20.0070.0309.04
5.2.10.0060.0298.95
5.2.00.0030.0318.81
5.1.60.0030.0268.08
5.1.50.0020.0308.08
5.1.40.0070.0288.07
5.1.30.0060.0338.42
5.1.20.0040.0328.44
5.1.10.0060.0268.16
5.1.00.0030.0288.17
5.0.50.0040.0206.64
5.0.40.0030.0226.51
5.0.30.0050.0326.31
5.0.20.0040.0216.28
5.0.10.0080.0266.27
5.0.00.0020.0336.25
4.4.90.0030.0174.77
4.4.80.0040.0144.75
4.4.70.0040.0154.76
4.4.60.0040.0174.76
4.4.50.0040.0174.77
4.4.40.0050.0294.71
4.4.30.0050.0154.76
4.4.20.0030.0194.84
4.4.10.0030.0164.85
4.4.00.0030.0254.76
4.3.110.0010.0174.67
4.3.100.0030.0144.67
4.3.90.0030.0144.63
4.3.80.0020.0254.59
4.3.70.0020.0164.63
4.3.60.0050.0124.63
4.3.50.0010.0184.62
4.3.40.0020.0244.54
4.3.30.0000.0173.30
4.3.20.0020.0163.27
4.3.10.0020.0163.24
4.3.00.0030.0207.26

preferences:
42.79 ms | 401 KiB | 5 Q