3v4l.org

run code in 300+ PHP versions simultaneously
<?php DEFINE('FILTER_OPTIONS', ['odd', 'even']); /* Array filtering * * @param $array array the input array * @param $filterParameter string 'odd' or 'even' * * @return array|bool it returns the filtered array. In any other case it should return false. */ function filterArray($array, $filterParameter) { if (! is_array($array) || ! in_array($filterParameter, FILTER_OPTIONS)) { return false; } return array_filter($array, function ($e) use ($filterParameter) { return $filterParameter === 'odd' ? $e % 2 === 1 : $e % 2 === 0; }); } $array = [1,2,3,4,5,6,7]; var_dump(filterArray(1, 'odd'));

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.0140.00718.31
8.3.50.0070.01416.27
8.3.40.0040.01118.84
8.3.30.0110.00418.59
8.3.20.0080.00020.31
8.3.10.0100.00021.59
8.3.00.0000.00819.66
8.2.180.0000.01516.75
8.2.170.0120.00322.96
8.2.160.0070.00719.32
8.2.150.0050.00324.18
8.2.140.0060.00324.66
8.2.130.0040.00419.70
8.2.120.0040.00426.35
8.2.110.0000.00822.08
8.2.100.0030.01017.91
8.2.90.0070.00319.22
8.2.80.0030.00617.97
8.2.70.0000.00817.50
8.2.60.0050.00317.93
8.2.50.0070.00318.10
8.2.40.0050.00322.29
8.2.30.0030.00619.37
8.2.20.0040.00418.09
8.2.10.0000.00818.07
8.2.00.0050.00217.95
8.1.280.0070.01425.92
8.1.270.0050.00322.19
8.1.260.0000.00726.35
8.1.250.0060.00328.09
8.1.240.0080.00023.76
8.1.230.0070.00322.21
8.1.220.0040.00417.74
8.1.210.0000.00818.77
8.1.200.0060.00317.35
8.1.190.0000.00817.35
8.1.180.0040.00418.10
8.1.170.0030.00618.59
8.1.160.0040.00419.09
8.1.150.0040.00418.89
8.1.140.0040.00419.54
8.1.130.0040.00418.81
8.1.120.0030.00317.50
8.1.110.0070.00317.30
8.1.100.0000.00717.52
8.1.90.0000.00817.49
8.1.80.0000.00717.48
8.1.70.0040.00417.42
8.1.60.0040.00417.58
8.1.50.0000.00817.52
8.1.40.0050.00317.38
8.1.30.0080.00017.67
8.1.20.0050.00317.63
8.1.10.0040.00417.43
8.1.00.0000.00717.37
8.0.300.0020.00518.77
8.0.290.0040.00416.63
8.0.280.0030.00318.37
8.0.270.0000.00717.26
8.0.260.0060.00018.93
8.0.250.0070.00016.82
8.0.240.0070.00016.86
8.0.230.0070.00016.95
8.0.220.0040.00416.91
8.0.210.0030.00316.83
8.0.200.0040.00416.93
8.0.190.0030.00616.93
8.0.180.0070.00016.92
8.0.170.0070.00016.93
8.0.160.0050.00316.85
8.0.150.0080.00016.80
8.0.140.0040.00416.90
8.0.130.0000.00513.32
8.0.120.0040.00416.89
8.0.110.0040.00416.96
8.0.100.0080.00016.79
8.0.90.0070.00016.85
8.0.80.0090.00616.89
8.0.70.0040.00416.73
8.0.60.0040.00416.69
8.0.50.0000.00816.84
8.0.30.0050.01317.19
8.0.20.0100.00917.40
8.0.10.0040.00417.07
8.0.00.0140.00316.70
7.4.330.0020.00215.55
7.4.320.0030.00316.65
7.4.300.0000.00616.62
7.4.290.0000.00716.59
7.4.280.0000.00716.65
7.4.270.0040.00416.54
7.4.260.0070.00016.44
7.4.250.0000.00716.62
7.4.240.0070.00016.59
7.4.230.0030.00316.68
7.4.220.0140.00716.63
7.4.210.0130.00316.55
7.4.200.0000.00716.72
7.4.160.0100.00716.53
7.4.150.0100.00717.40
7.4.140.0110.00817.86
7.4.130.0090.01516.73
7.4.120.0100.00816.48
7.4.110.0100.00616.55
7.4.100.0120.00916.59
7.4.90.0120.00616.55
7.4.80.0120.00919.39
7.4.70.0060.01216.60
7.4.60.0030.01316.57
7.4.50.0030.00916.54
7.4.40.0070.01016.44
7.4.30.0040.01216.22
7.4.00.0070.01014.89
7.3.330.0000.00513.10
7.3.320.0000.00513.02
7.3.310.0000.00716.22
7.3.300.0070.00016.23
7.3.290.0050.00916.25
7.3.280.0070.00816.23
7.3.270.0120.00617.40
7.3.260.0070.01116.35
7.3.250.0060.01116.35
7.3.240.0080.01016.39
7.3.230.0130.00616.57
7.3.210.0060.00916.17
7.3.200.0090.00716.27
7.3.190.0110.00616.62
7.3.180.0160.00016.45
7.3.170.0100.01016.22
7.3.160.0110.00416.24
7.2.330.0060.01216.35
7.2.320.0090.00916.57
7.2.310.0060.01016.47
7.2.300.0130.00316.64
7.2.290.0110.01116.72
7.2.60.0030.00916.63
7.2.50.0100.00316.89
7.1.200.0040.00415.64
7.1.70.0550.01015.14
7.1.60.0650.01033.34
7.1.50.0630.01432.97
7.1.40.0580.01332.72
7.1.30.0700.01332.47
7.1.20.0610.01432.70
7.1.10.0480.01014.70
7.1.00.0720.01014.66
7.0.200.1830.00314.83
7.0.190.0560.01314.70
7.0.180.0700.01014.19
7.0.170.0770.00314.50
7.0.160.0570.01014.32
7.0.150.0510.00714.34
7.0.140.0500.00714.52
7.0.130.0510.00714.59
7.0.120.0510.00614.71
7.0.110.0440.01414.69
7.0.100.0490.01014.45
7.0.90.0540.00614.50
7.0.80.0550.01014.43
7.0.70.0550.00314.37
7.0.60.0520.00714.25
7.0.50.0640.00314.61
7.0.40.0550.00714.73
7.0.30.0640.00014.90
7.0.20.0520.01014.39
7.0.10.0560.01114.84
7.0.00.0500.00914.63

preferences:
58.28 ms | 401 KiB | 5 Q