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.0110.00716.75
8.3.50.0190.00316.34
8.3.40.0070.00718.82
8.3.30.0060.00918.84
8.3.20.0080.00020.39
8.3.10.0040.00421.87
8.3.00.0040.00420.96
8.2.180.0070.00718.17
8.2.170.0040.01122.96
8.2.160.0040.01122.10
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0080.00022.02
8.2.120.0070.00026.35
8.2.110.0000.01022.14
8.2.100.0070.00417.84
8.2.90.0000.00919.17
8.2.80.0060.00317.97
8.2.70.0050.00517.75
8.2.60.0040.00418.16
8.2.50.0040.00418.10
8.2.40.0040.00422.20
8.2.30.0030.00519.29
8.2.20.0030.00518.16
8.2.10.0080.00018.03
8.2.00.0070.00018.13
8.1.280.0110.00425.92
8.1.270.0070.00723.99
8.1.260.0040.00426.35
8.1.250.0110.00428.09
8.1.240.0150.00023.98
8.1.230.0000.01217.71
8.1.220.0080.00017.74
8.1.210.0080.00018.77
8.1.200.0050.00517.35
8.1.190.0090.00017.35
8.1.180.0080.00018.10
8.1.170.0000.00818.50
8.1.160.0040.00419.11
8.1.150.0000.00718.92
8.1.140.0040.00419.60
8.1.130.0030.00318.82
8.1.120.0070.00417.38
8.1.110.0040.00417.37
8.1.100.0080.00017.38
8.1.90.0030.00517.54
8.1.80.0040.00417.53
8.1.70.0030.00317.48
8.1.60.0030.00617.52
8.1.50.0040.00417.55
8.1.40.0060.00317.47
8.1.30.0000.00717.60
8.1.20.0060.00317.65
8.1.10.0050.00317.57
8.1.00.0030.00517.52
8.0.300.0040.00418.77
8.0.290.0050.00316.75
8.0.280.0030.00318.46
8.0.270.0000.00717.26
8.0.260.0040.00416.88
8.0.250.0040.00416.95
8.0.240.0000.00716.74
8.0.230.0050.00316.84
8.0.220.0030.00316.79
8.0.210.0070.00016.84
8.0.200.0000.00616.96
8.0.190.0060.00317.02
8.0.180.0040.00416.86
8.0.170.0000.00716.88
8.0.160.0040.00416.84
8.0.150.0000.00716.71
8.0.140.0030.00316.87
8.0.130.0000.00713.30
8.0.120.0050.00316.77
8.0.110.0000.00816.73
8.0.100.0040.00416.76
8.0.90.0040.00416.90
8.0.80.0090.00816.89
8.0.70.0070.00016.80
8.0.60.0000.00816.91
8.0.50.0050.00216.91
8.0.30.0090.01017.14
8.0.20.0150.00517.40
8.0.10.0000.00717.10
8.0.00.0030.01616.55
7.4.330.0030.00315.55
7.4.320.0030.00316.61
7.4.300.0000.00716.53
7.4.290.0060.00316.48
7.4.280.0000.00816.54
7.4.270.0050.00316.43
7.4.260.0080.00016.50
7.4.250.0000.00716.46
7.4.240.0050.00216.54
7.4.230.0050.00216.46
7.4.220.0100.01016.70
7.4.210.0080.00616.39
7.4.200.0070.00016.52
7.4.160.0110.00616.43
7.4.150.0060.01217.40
7.4.140.0130.00517.86
7.4.130.0170.01016.53
7.4.120.0100.01316.61
7.4.110.0130.00316.55
7.4.100.0120.00616.40
7.4.90.0150.00316.60
7.4.80.0130.00319.39
7.4.70.0160.00716.42
7.4.60.0070.01016.43
7.4.50.0060.00616.36
7.4.40.0090.00916.76
7.4.30.0100.00616.51
7.4.00.0080.00914.93
7.3.330.0000.00713.28
7.3.320.0030.00313.20
7.3.310.0000.00716.34
7.3.300.0030.00516.38
7.3.290.0080.00616.30
7.3.280.0060.01016.31
7.3.270.0110.00717.40
7.3.260.0120.00616.53
7.3.250.0110.00816.41
7.3.240.0080.01116.63
7.3.230.0100.01016.45
7.3.210.0090.00916.53
7.3.200.0060.01216.25
7.3.190.0080.00816.58
7.3.180.0110.01116.59
7.3.170.0080.00816.69
7.3.160.0080.00816.36
7.3.120.0050.01214.94
7.3.110.0070.01114.94
7.3.100.0070.00714.94
7.3.90.0020.01114.87
7.3.80.0030.00914.76
7.3.70.0020.01214.72
7.3.60.0080.00514.63
7.3.50.0050.00914.74
7.3.40.0060.00414.94
7.3.30.0050.00514.78
7.3.20.0090.00616.66
7.3.10.0030.01116.79
7.3.00.0060.01016.68
7.2.330.0070.01616.48
7.2.320.0200.00316.78
7.2.310.0130.01016.76
7.2.300.0100.01316.58
7.2.290.0090.00916.67
7.2.250.0070.01015.00
7.2.240.0090.00715.00
7.2.230.0050.00914.85
7.2.220.0020.00915.03
7.2.210.0070.00915.01
7.2.200.0060.00715.15
7.2.190.0080.00815.01
7.2.180.0060.00815.01
7.2.170.0060.00715.15
7.2.60.0110.00416.86
7.2.00.0040.01119.48
7.1.330.0070.00515.78
7.1.320.0040.00715.79
7.1.310.0060.00815.73
7.1.300.0120.00315.70
7.1.290.0020.00815.91
7.1.280.0060.00515.80
7.1.270.0030.01015.71
7.1.260.0080.00815.60
7.1.200.0030.01015.81
7.1.100.0000.00818.13
7.1.70.0000.00716.93
7.1.60.0270.02033.43
7.1.50.0500.01332.77
7.1.40.0300.01332.64
7.1.30.0330.01332.69
7.1.20.0430.01032.79
7.1.10.0400.00714.72
7.1.00.0230.01014.84
7.0.200.0230.00714.96
7.0.190.0170.01315.09
7.0.180.0330.00714.63
7.0.170.0170.01314.27
7.0.160.0230.01314.38
7.0.150.0200.01014.44
7.0.140.0270.00714.47
7.0.130.0270.01714.79
7.0.120.1370.01314.71
7.0.110.0230.01014.45
7.0.100.0230.01014.48
7.0.90.0270.01014.68
7.0.80.0230.01014.71
7.0.70.0200.01014.70
7.0.60.0200.01314.08
7.0.50.0270.01014.34
7.0.40.0230.01014.77
7.0.30.0100.00314.71
7.0.20.0430.00714.59
7.0.10.0300.01314.67
7.0.00.0270.01014.54

preferences:
41.32 ms | 401 KiB | 5 Q