3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Extract values from an array, and return the results * * @param array $array The array to filter * @param callable|string $callback Function to filter the array with * * @return array A new array containing the filtered elements */ function array_excise(array &$array, callable|string $callback): array { $result = []; if (!is_callable($callback)) { return $result; } foreach ($array as $key => $value) { if (call_user_func($callback, $value)) { $result[$key] = $value; unset($array[$key]); } } return $result; } /* $people = [ ["name" => "Billy Jean", "filter" => false], ["name" => "Ronald Reagan", "filter" => true], ["name" => "Bill Clinton", "filter" => true], ["name" => "Michael Jackson", "filter" => false], ["name" => "Johnny Cash", "filter" => false], ]; $presidents = array_excise($people, function($p){ return $p["filter"]; }); var_export(compact(['people', 'presidents'])); */ $numbers = [ [1, 1, 1], [1, 1, 0], [1, 0, 0], [0, 0, 0] ]; $noZeros = array_excise($numbers, 'array_product'); var_export(compact(['numbers', 'noZeros']));

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.4.120.0070.00724.04
8.4.110.0120.00922.28
8.4.100.0100.00917.47
8.4.90.0090.00818.77
8.4.80.0030.00517.96
8.4.70.0130.00717.87
8.4.60.0100.01118.75
8.4.50.0120.00819.31
8.4.40.0040.01519.49
8.4.30.0110.01120.61
8.4.20.0100.00018.06
8.4.10.0060.00321.90
8.3.250.0110.00818.69
8.3.240.0080.01117.20
8.3.230.0130.00716.57
8.3.220.0130.00617.11
8.3.210.0070.01016.72
8.3.200.0060.00316.47
8.3.190.0030.00517.17
8.3.180.0110.00816.63
8.3.170.0090.00917.03
8.3.160.0070.01018.56
8.3.150.0100.01020.93
8.3.140.0090.00916.43
8.3.130.0100.01018.46
8.3.120.0100.00720.84
8.3.110.0060.00320.94
8.3.100.0070.00324.06
8.3.90.0070.00326.77
8.3.80.0030.00618.55
8.3.70.0090.00616.75
8.3.60.0140.00716.88
8.3.50.0110.01119.98
8.3.40.0130.00021.83
8.3.30.0070.00718.79
8.3.20.0040.00424.18
8.3.10.0080.00024.66
8.3.00.0080.00026.16
8.2.290.0060.00320.46
8.2.280.0050.00318.31
8.2.270.0100.00717.10
8.2.260.0070.00718.49
8.2.250.0090.00918.28
8.2.240.0080.00818.74
8.2.230.0040.00422.58
8.2.220.0030.00637.54
8.2.210.0090.00926.77
8.2.200.0040.00416.88
8.2.190.0120.00316.75
8.2.180.0080.00825.92
8.2.170.0070.00722.96
8.2.160.0070.00722.96
8.2.150.0050.00325.66
8.2.140.0050.00324.66
8.2.130.0000.00826.16
8.2.120.0000.00726.16
8.2.110.0040.00720.95
8.2.100.0150.00518.26
8.2.90.0040.00417.75
8.2.80.0000.00818.91
8.2.70.0040.00417.61
8.2.60.0080.00317.93
8.2.50.0040.00418.04
8.2.40.0080.00019.97
8.2.30.0040.00418.07
8.2.20.0070.00020.50
8.2.10.0040.00418.06
8.2.00.0030.00619.36
8.1.330.0100.00823.63
8.1.320.0090.01016.25
8.1.310.0000.00918.32
8.1.300.0060.00317.77
8.1.290.0030.00930.84
8.1.280.0040.01125.92
8.1.270.0030.00623.99
8.1.260.0060.00326.35
8.1.250.0000.00728.09
8.1.240.0060.00319.21
8.1.230.0070.00422.05
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0060.00317.23
8.1.190.0040.00417.22
8.1.180.0000.00818.97
8.1.170.0040.00417.65
8.1.160.0040.00418.94
8.1.150.0000.00718.68
8.1.140.0040.00417.33
8.1.130.0080.00017.36
8.1.120.0040.00417.47
8.1.110.0040.00417.34
8.1.100.0000.00717.36
8.1.90.0040.00417.35
8.1.80.0100.00517.37
8.1.70.0070.00617.39
8.1.60.0100.00317.54
8.1.50.0110.00417.38
8.1.40.0100.00717.44
8.1.30.0060.01217.63
8.1.20.0140.00517.59
8.1.10.0110.00817.45
8.1.00.0100.01017.48
8.0.300.0030.00518.77
8.0.290.0060.00316.75
8.0.280.0060.00318.50
8.0.270.0030.00316.80
8.0.260.0040.00416.89
8.0.250.0000.00716.91
8.0.240.0030.00516.98
8.0.230.0040.00416.97
8.0.220.0000.00716.96
8.0.210.0060.00616.91
8.0.200.0150.00316.95
8.0.190.0090.00916.94
8.0.180.0070.00916.98
8.0.170.0110.00616.88
8.0.160.0140.00416.93
8.0.150.0120.00016.75
8.0.140.0050.00816.78
8.0.130.0070.00516.80
8.0.120.0070.00716.89
8.0.110.0110.00516.98
8.0.100.0130.00516.82
8.0.90.0110.00816.89
8.0.80.0050.01416.86
8.0.70.0160.00316.88
8.0.60.0180.00016.93
8.0.50.0130.00316.89
8.0.30.0140.00216.87
8.0.20.0120.00316.84
8.0.10.0070.00717.04
7.4.330.0000.00615.55
7.4.320.0030.00316.34
7.4.300.0030.00316.31
7.4.290.0090.00016.39
7.4.280.0060.00316.38
7.4.270.0050.00516.39
7.4.260.0040.00416.28
7.4.250.0110.00016.39
7.4.240.0140.00516.39
7.4.230.0170.00316.44
7.4.220.0120.00616.29
7.4.210.0190.00016.37
7.4.200.0120.00616.35
7.4.190.0070.00716.35
7.4.180.0090.00516.40
7.4.160.0100.00716.39
7.4.150.0110.00716.34
7.4.140.0170.00016.29
7.4.130.0100.00616.15
7.4.120.0180.00016.08
7.4.110.0070.00716.17
7.4.100.0080.00816.24
7.4.90.0040.01316.21
7.4.80.0060.01016.24
7.4.70.0120.00316.21
7.4.60.0120.00416.22
7.4.50.0130.00316.18
7.4.40.0100.00516.14
7.4.30.0100.00316.26
7.4.20.0070.00716.18
7.4.10.0160.00016.14
7.4.00.0130.00416.25

preferences:
32.45 ms | 403 KiB | 5 Q