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); } } continue; // 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.0030.01316.75
8.3.50.0140.00416.63
8.3.40.0000.01518.98
8.3.30.0110.00418.63
8.3.20.0040.00420.16
8.3.10.0050.00321.73
8.3.00.0070.00020.80
8.2.180.0070.00718.29
8.2.170.0150.00622.96
8.2.160.0070.00722.11
8.2.150.0050.00324.18
8.2.140.0000.00724.66
8.2.130.0050.00222.08
8.2.120.0080.00026.35
8.2.110.0130.00320.70
8.2.100.0080.00417.91
8.2.90.0000.00819.23
8.2.80.0040.00418.05
8.2.70.0000.00817.75
8.2.60.0000.00817.93
8.2.50.0030.00518.16
8.2.40.0000.00822.27
8.2.30.0040.00420.97
8.2.20.0030.00518.11
8.2.10.0000.00818.20
8.2.00.0040.00418.20
8.1.280.0070.00725.92
8.1.270.0100.00723.90
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0090.00322.07
8.1.230.0060.00623.93
8.1.220.0000.00817.79
8.1.210.0030.00518.77
8.1.200.0000.00917.35
8.1.190.0040.00417.10
8.1.180.0000.00718.10
8.1.170.0030.00618.50
8.1.160.0050.00219.03
8.1.150.0000.00818.84
8.1.140.0000.00819.59
8.1.130.0000.00718.89
8.1.120.0030.00717.36
8.1.110.0040.00417.50
8.1.100.0000.00817.41
8.1.90.0040.00417.51
8.1.80.0000.00717.47
8.1.70.0030.00617.48
8.1.60.0060.00317.61
8.1.50.0080.00017.55
8.1.40.0040.00417.55
8.1.30.0000.00817.52
8.1.20.0040.00417.50
8.1.10.0040.00417.67
8.1.00.0050.00217.53
8.0.300.0080.00018.77
8.0.290.0000.00716.75
8.0.280.0030.00518.51
8.0.270.0070.00017.24
8.0.260.0030.00316.72
8.0.250.0070.00017.04
8.0.240.0040.00416.84
8.0.230.0040.00417.00
8.0.220.0040.00316.89
8.0.210.0000.00716.93
8.0.200.0030.00316.98
8.0.190.0060.00316.82
8.0.180.0040.00416.95
8.0.170.0000.00716.84
8.0.160.0030.00317.01
8.0.150.0040.00416.79
8.0.140.0040.00416.90
8.0.130.0040.00213.33
8.0.120.0080.00016.90
8.0.110.0020.00516.82
8.0.100.0030.00517.02
8.0.90.0000.00716.74
8.0.80.0090.00616.95
8.0.70.0000.00716.74
8.0.60.0040.00416.90
8.0.50.0070.00016.96
8.0.30.0120.01017.14
8.0.20.0120.00917.40
8.0.10.0030.00516.94
8.0.00.0060.01216.93
7.4.330.0050.00015.55
7.4.320.0020.00516.63
7.4.300.0040.00416.57
7.4.290.0120.00016.52
7.4.280.0000.00816.61
7.4.270.0030.00516.51
7.4.260.0030.00316.56
7.4.250.0030.00316.48
7.4.240.0050.00216.51
7.4.230.0050.00316.41
7.4.220.0130.01316.55
7.4.210.0090.00616.63
7.4.200.0070.00016.36
7.4.160.0050.01116.58
7.4.150.0150.01117.40
7.4.140.0100.00817.86
7.4.130.0210.00516.43
7.4.120.0120.01216.58
7.4.110.0100.01316.63
7.4.100.0140.00716.56
7.4.90.0070.01016.51
7.4.80.0170.00019.39
7.4.70.0090.00616.46
7.4.60.0080.00816.44
7.4.50.0090.00616.27
7.4.40.0110.00516.49
7.4.30.0080.00816.51
7.4.00.0080.01015.14
7.3.330.0000.00513.08
7.3.320.0060.00013.25
7.3.310.0030.00316.31
7.3.300.0070.00016.29
7.3.290.0100.00816.39
7.3.280.0090.00816.35
7.3.270.0110.00617.40
7.3.260.0080.00916.48
7.3.250.0120.00716.56
7.3.240.0080.01016.58
7.3.230.0080.01116.43
7.3.210.0110.00616.41
7.3.200.0060.01116.38
7.3.190.0140.00316.33
7.3.180.0030.01516.52
7.3.170.0090.00616.61
7.3.160.0060.00916.39
7.3.120.0100.01014.89
7.3.110.0030.01114.94
7.3.100.0080.00514.67
7.3.90.0060.00614.77
7.3.80.0060.01214.84
7.3.70.0040.00814.92
7.3.60.0080.00415.05
7.3.50.0030.01014.75
7.3.40.0000.01214.56
7.3.30.0090.00614.91
7.3.20.0060.00316.81
7.3.10.0100.00316.54
7.3.00.0050.00516.70
7.2.330.0060.01116.65
7.2.320.0110.01116.79
7.2.310.0130.00416.53
7.2.300.0060.00916.63
7.2.290.0060.01016.66
7.2.250.0070.01315.38
7.2.240.0040.01414.88
7.2.230.0140.00015.29
7.2.220.0030.00914.98
7.2.210.0080.00415.00
7.2.200.0030.01215.30
7.2.190.0070.00714.98
7.2.180.0090.00314.95
7.2.170.0000.00914.73
7.2.60.0070.00716.81
7.2.00.0070.00719.48
7.1.330.0060.00915.59
7.1.320.0030.00615.81
7.1.310.0060.00315.89
7.1.300.0040.00415.82
7.1.290.0030.00515.83
7.1.280.0060.00915.81
7.1.270.0000.01115.44
7.1.260.0060.00315.76
7.1.200.0070.00415.92
7.1.100.0000.01218.22
7.1.70.0000.00717.17
7.1.60.0230.01733.38
7.1.50.0900.01333.18
7.1.40.0630.01032.62
7.1.30.0700.01032.72
7.1.20.0470.01332.85
7.1.10.0330.01014.81
7.1.00.0530.01015.09
7.0.200.0200.01015.00
7.0.190.0570.00715.10
7.0.180.0330.01314.63
7.0.170.0400.01014.39
7.0.160.0330.01314.41
7.0.150.0270.01014.57
7.0.140.0270.01714.71
7.0.130.0430.01014.91
7.0.120.0500.01014.67
7.0.110.0370.01014.52
7.0.100.0370.01014.59
7.0.90.0000.01314.47
7.0.80.0270.01314.30
7.0.70.0430.01014.45
7.0.60.0400.00714.35
7.0.50.0300.01014.52
7.0.40.0070.01014.58
7.0.30.0300.01014.66
7.0.20.0400.00714.68
7.0.10.0600.01014.39
7.0.00.0070.01314.50

preferences:
41.68 ms | 401 KiB | 5 Q