3v4l.org

run code in 300+ PHP versions simultaneously
<?php $query_input = [ '_or'=>[ ['cats'=>1], ['dogs'=>1] ] ]; $results = [ ['id'=>0,'cats'=>0,'dogs'=>0], ['id'=>1,'cats'=>0,'dogs'=>0,'lizards'=>3], ['id'=>2,'cats'=>0,'dogs'=>1], ['id'=>3,'cats'=>1,'dogs'=>0], ['id'=>4,'cats'=>1,'dogs'=>1] ]; // hackkk both the filter and find methods need significant cleanup if (isset($query_input['_or'])) { foreach ($query_input['_or'] as $key=>$value) { $query_where = [$key, '_OR', null]; } } $out = []; $skip = []; foreach ($results as $result) { foreach ($query_where as $where) { list($key, $comp, $value) = $where; if (!isset($result[$key])) { $skip = ['!isset', $key]; continue; } // the data is not in the result, skip check switch ($comp) { case '_OR': foreach ($query_input['_or'][$key] as $or_item) { foreach ($or_item as $comp_key=>$comp_value) { if ($result[$comp_key] != $comp_value) { continue(2); } } break; // as long as the script hits here, the result will be kep } break; case '=': if ($result[$key] != $value) { $skip[] = [$result[$key],$value,'=',$key]; continue(3); } break; case 'LIKE': $pos = strpos($value,'%'); if ($pos===false) $pos = strlen($value); if (substr($result[$key],0,$pos) !== substr($value,0,$pos)) { $skip[] = [$result[$key],$value,'LIKE',$key]; continue(3); } break; } } } $out[] = $result; var_dump($out);

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.0100.01016.38
8.3.50.0150.00016.64
8.3.40.0100.00618.57
8.3.30.0090.00618.68
8.3.20.0000.00820.34
8.3.10.0040.00421.64
8.3.00.0050.00320.84
8.2.180.0070.00718.06
8.2.170.0090.00622.96
8.2.160.0070.00722.13
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0050.00321.99
8.2.120.0090.00026.35
8.2.110.0090.00620.35
8.2.100.0060.00617.84
8.2.90.0080.00019.12
8.2.80.0040.00418.05
8.2.70.0030.00517.75
8.2.60.0050.00317.93
8.2.50.0040.00418.10
8.2.40.0040.00422.34
8.2.30.0000.00719.25
8.2.20.0050.00317.96
8.2.10.0050.00318.06
8.2.00.0000.00718.21
8.1.280.0090.00625.92
8.1.270.0030.00523.79
8.1.260.0000.00726.35
8.1.250.0080.00028.09
8.1.240.0060.00320.84
8.1.230.0090.00319.16
8.1.220.0040.00417.77
8.1.210.0050.00318.77
8.1.200.0040.00417.35
8.1.190.0060.00317.23
8.1.180.0040.00418.10
8.1.170.0080.00018.65
8.1.160.0050.00319.03
8.1.150.0040.00418.91
8.1.140.0000.00719.64
8.1.130.0030.00318.84
8.1.120.0030.00717.41
8.1.110.0040.00417.36
8.1.100.0000.00817.51
8.1.90.0040.00417.38
8.1.80.0000.00717.46
8.1.70.0040.00417.50
8.1.60.0030.00617.63
8.1.50.0030.00617.46
8.1.40.0000.00717.56
8.1.30.0030.00617.64
8.1.20.0030.00617.66
8.1.10.0030.00617.60
8.1.00.0040.00417.53
8.0.300.0030.00518.77
8.0.290.0000.00816.63
8.0.280.0080.00018.38
8.0.270.0000.00717.38
8.0.260.0000.00816.80
8.0.250.0030.00316.88
8.0.240.0070.00016.77
8.0.230.0030.00316.98
8.0.220.0020.00516.91
8.0.210.0050.00317.00
8.0.200.0030.00316.88
8.0.190.0060.00616.98
8.0.180.0050.00316.95
8.0.170.0000.00716.93
8.0.160.0000.00716.80
8.0.150.0000.00716.84
8.0.140.0040.00416.89
8.0.130.0050.00313.26
8.0.120.0000.00816.90
8.0.110.0050.00216.96
8.0.100.0020.00516.84
8.0.90.0040.00416.79
8.0.80.0040.01516.92
8.0.70.0040.00416.78
8.0.60.0040.00416.96
8.0.50.0040.00416.97
8.0.30.0050.01217.06
8.0.20.0100.00817.40
8.0.10.0020.00517.06
8.0.00.0070.01116.58
7.4.330.0020.00215.55
7.4.320.0000.00616.60
7.4.300.0000.00716.60
7.4.290.0030.00616.66
7.4.280.0030.00516.43
7.4.270.0070.00016.63
7.4.260.0000.00716.37
7.4.250.0070.00016.49
7.4.240.0030.00316.58
7.4.230.0030.00316.60
7.4.220.0090.00916.41
7.4.210.0070.00716.66
7.4.200.0000.00716.28
7.4.160.0030.01316.45
7.4.150.0000.01817.40
7.4.140.0090.01017.86
7.4.130.0210.00416.44
7.4.120.0160.00516.58
7.4.110.0070.01016.50
7.4.100.0040.01316.60
7.4.90.0100.00716.46
7.4.80.0040.01319.39
7.4.70.0070.01016.52
7.4.60.0120.00416.68
7.4.50.0000.01316.55
7.4.40.0100.01016.63
7.4.30.0060.01016.63
7.4.10.0000.01614.72
7.4.00.0050.01015.13
7.3.330.0050.00013.07
7.3.320.0030.00313.27
7.3.310.0070.00016.48
7.3.300.0030.00316.25
7.3.290.0060.01016.30
7.3.280.0080.00716.37
7.3.270.0040.01417.40
7.3.260.0100.01016.37
7.3.250.0130.01016.46
7.3.240.0100.00816.56
7.3.230.0190.00616.61
7.3.210.0080.00916.60
7.3.200.0060.01016.43
7.3.190.0060.01216.46
7.3.180.0080.00916.39
7.3.170.0100.00716.38
7.3.160.0040.01216.25
7.3.130.0030.01414.91
7.3.120.0080.00714.77
7.3.110.0070.01014.95
7.3.100.0070.00914.65
7.3.90.0050.01014.78
7.3.80.0070.00514.62
7.3.70.0050.00514.66
7.3.60.0030.01214.65
7.3.50.0050.00714.68
7.3.40.0070.00714.75
7.3.30.0050.00814.82
7.3.20.0080.00616.67
7.3.10.0020.01416.75
7.3.00.0060.00516.55
7.2.330.0090.00916.79
7.2.320.0120.00816.37
7.2.310.0100.00616.63
7.2.300.0100.00616.49
7.2.290.0130.00316.50
7.2.260.0110.00815.02
7.2.250.0100.00715.22
7.2.240.0020.01015.23
7.2.230.0030.01115.27
7.2.220.0080.00515.05
7.2.210.0050.00814.90
7.2.200.0050.00715.21
7.2.190.0030.01015.16
7.2.180.0020.01215.14
7.2.170.0050.00614.98
7.2.160.0050.00814.85
7.2.150.0120.00516.72
7.2.140.0050.00816.88
7.2.130.0040.00817.10
7.2.120.0050.01016.94
7.2.110.0070.00717.05
7.2.100.0030.00716.84
7.2.90.0040.01317.03
7.2.80.0060.00716.92
7.2.70.0050.01216.70
7.2.60.0050.00717.06
7.2.50.0100.00317.03
7.2.40.0030.01216.82
7.2.30.0040.00716.98
7.2.20.0080.00516.85
7.2.10.0090.00317.12
7.2.00.0030.01016.88
7.1.330.0090.00615.77
7.1.320.0020.01315.76
7.1.310.0060.01015.75
7.1.300.0000.01115.90
7.1.290.0080.00715.86
7.1.280.0050.01015.72
7.1.270.0060.00815.90
7.1.260.0070.00515.78
7.1.250.0070.00715.77
7.1.240.0060.00915.87
7.1.230.0070.00515.72
7.1.220.0070.00315.58
7.1.210.0080.00815.87
7.1.200.0110.00315.83
7.1.190.0030.01015.66
7.1.180.0050.00615.65
7.1.170.0090.00515.64
7.1.160.0080.00515.94
7.1.150.0040.01015.77
7.1.140.0070.00515.89
7.1.130.0030.00915.80
7.1.120.0060.00415.63
7.1.110.0060.00615.92
7.1.100.0080.00615.71
7.1.90.0070.00515.76
7.1.80.0010.01115.89
7.1.70.0040.00716.23
7.1.60.0180.01121.68
7.1.50.0160.00921.63
7.1.40.0200.01121.30
7.1.30.0180.00521.37
7.1.20.0220.00421.39
7.1.10.0150.00815.53
7.1.00.0130.00915.40
7.0.330.0000.01415.15
7.0.320.0050.00515.24
7.0.310.0060.00615.36
7.0.300.0050.00615.31
7.0.290.0020.01315.51
7.0.280.0040.00815.34
7.0.270.0070.00515.17
7.0.260.0090.00315.31
7.0.250.0080.00515.43
7.0.240.0010.01215.56
7.0.230.0040.01115.56
7.0.220.0030.00515.52
7.0.210.0030.00815.41
7.0.200.0120.00715.28
7.0.190.0140.00815.23
7.0.180.0150.00915.08
7.0.170.0110.01015.12
7.0.160.0340.00514.95
7.0.150.0140.00715.13
7.0.140.0180.00915.20
7.0.130.0140.01115.17
7.0.120.0130.01015.13
7.0.110.0120.01115.12
7.0.100.0110.00715.09
7.0.90.0140.00615.05
7.0.80.0160.00515.10
7.0.70.0150.00315.05
7.0.60.0130.00514.93
7.0.50.0130.00815.20
7.0.40.0120.00713.86
7.0.30.0120.00713.95
7.0.20.0140.00713.87
7.0.10.0110.01013.82
7.0.00.0180.00313.78
5.6.400.0080.00814.50
5.6.390.0040.01014.34
5.6.380.0060.00414.64
5.6.370.0030.01014.66
5.6.360.0060.00714.45
5.6.350.0060.00914.42
5.6.340.0060.00814.29
5.6.330.0060.00614.47
5.6.320.0050.00914.45
5.6.310.0040.00714.40
5.6.300.0050.00914.49
5.6.290.0030.01314.40
5.6.280.0040.01314.19
5.6.270.0030.01014.56
5.6.260.0020.00714.30
5.6.250.0050.00914.51
5.6.240.0060.00614.49
5.6.230.0050.00914.53
5.6.220.0050.00714.44
5.6.210.0100.00114.43
5.6.200.0030.01114.29
5.6.190.0040.01114.25
5.6.180.0080.00514.46
5.6.170.0060.00414.61
5.6.160.0060.00714.28
5.6.150.0060.00814.41
5.6.140.0070.00414.39
5.6.130.0050.00614.48
5.6.120.0000.01114.34
5.6.110.0050.00814.35
5.6.100.0010.00714.36
5.6.90.0020.00914.37
5.6.80.0020.00814.17
5.6.70.0030.01114.31
5.6.60.0000.01214.21
5.6.50.0080.00814.34
5.6.40.0090.00614.09
5.6.30.0060.00614.25
5.6.20.0060.00714.22
5.6.10.0090.00714.14
5.6.00.0050.01014.21

preferences:
47.55 ms | 400 KiB | 5 Q