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]; } } var_dump($query_where); $out = []; $skip = []; foreach ($results as $result) { foreach ($query_where as $where) { list($key, $comp, $value) = $where; if ($comp !== '_OR' && !isset($result[$key])) { $skip = ['!isset', $key]; continue; } // the data is not in the result, skip check switch ($comp) { case '_OR': $or = false; foreach ($query_input['_or'][$key] as $or_item) { foreach ($or_item as $comp_key=>$comp_value) { if ($result[$comp_key] != $comp_value) { echo 1; continue(2); } } echo 2; var_dump($result,'okay'); $or = true; break; // as long as the script hits here, the result will be kep } if (!$or) continue(3); 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.0080.00818.43
8.3.50.0100.01316.46
8.3.40.0080.00818.79
8.3.30.0060.00918.67
8.3.20.0030.00620.16
8.3.10.0040.00421.76
8.3.00.0080.00020.84
8.2.180.0210.00018.29
8.2.170.0110.01122.96
8.2.160.0140.00021.91
8.2.150.0080.00024.18
8.2.140.0030.00524.66
8.2.130.0040.00422.14
8.2.120.0040.00426.35
8.2.110.0000.00920.57
8.2.100.0090.00317.84
8.2.90.0000.00819.23
8.2.80.0000.00818.03
8.2.70.0050.00317.50
8.2.60.0040.00418.16
8.2.50.0050.00318.10
8.2.40.0080.00022.34
8.2.30.0040.00421.09
8.2.20.0030.00518.22
8.2.10.0090.00018.16
8.2.00.0020.00518.21
8.1.280.0120.00625.92
8.1.270.0000.00823.82
8.1.260.0080.00026.35
8.1.250.0110.00328.09
8.1.240.0030.00720.89
8.1.230.0070.00419.16
8.1.220.0070.00317.79
8.1.210.0000.00918.77
8.1.200.0030.00617.22
8.1.190.0040.00417.23
8.1.180.0030.00618.10
8.1.170.0000.00818.48
8.1.160.0040.00419.05
8.1.150.0040.00420.53
8.1.140.0040.00419.71
8.1.130.0000.00718.80
8.1.120.0000.00917.48
8.1.110.0050.00217.39
8.1.100.0050.00317.45
8.1.90.0020.00517.51
8.1.80.0000.00817.52
8.1.70.0030.00617.52
8.1.60.0040.00417.63
8.1.50.0040.00417.59
8.1.40.0080.00017.62
8.1.30.0000.00917.62
8.1.20.0050.00317.53
8.1.10.0000.00817.55
8.1.00.0030.00617.61
8.0.300.0050.00218.77
8.0.290.0050.00316.63
8.0.280.0000.00718.34
8.0.270.0040.00417.41
8.0.260.0000.00616.86
8.0.250.0030.00316.95
8.0.240.0030.00516.76
8.0.230.0020.00516.89
8.0.220.0000.00816.96
8.0.210.0050.00316.96
8.0.200.0000.00717.00
8.0.190.0000.00816.99
8.0.180.0030.00616.96
8.0.170.0040.00416.92
8.0.160.0000.00816.89
8.0.150.0100.00016.91
8.0.140.0040.00416.80
8.0.130.0040.00213.25
8.0.120.0030.00716.92
8.0.110.0040.00416.97
8.0.100.0070.00016.95
8.0.90.0040.00416.75
8.0.80.0060.01016.82
8.0.70.0040.00416.93
8.0.60.0040.00416.76
8.0.50.0080.00016.77
8.0.30.0170.00517.19
8.0.20.0100.01117.40
8.0.10.0000.00717.00
8.0.00.0000.02317.00
7.4.330.0030.00315.55
7.4.320.0040.00416.47
7.4.300.0070.00016.63
7.4.290.0040.00416.61
7.4.280.0030.00616.63
7.4.270.0000.00716.55
7.4.260.0000.00716.68
7.4.250.0030.00316.50
7.4.240.0070.00016.45
7.4.230.0000.00716.38
7.4.220.0070.02016.48
7.4.210.0060.01016.50
7.4.200.0030.00316.72
7.4.160.0100.01016.45
7.4.150.0090.01017.40
7.4.140.0080.01217.86
7.4.130.0150.00916.60
7.4.120.0120.00716.59
7.4.110.0090.00916.39
7.4.100.0140.00816.66
7.4.90.0040.01516.49
7.4.80.0110.00819.39
7.4.70.0030.01416.67
7.4.60.0140.00516.56
7.4.50.0040.00716.70
7.4.40.0160.00716.38
7.4.30.0080.00816.70
7.4.00.0060.00614.75
7.3.330.0030.00313.12
7.3.320.0030.00313.23
7.3.310.0000.00716.20
7.3.300.0040.00416.35
7.3.290.0080.01016.33
7.3.280.0110.00716.33
7.3.270.0060.01317.40
7.3.260.0100.01116.45
7.3.250.0110.00916.44
7.3.240.0140.00516.55
7.3.230.0070.01316.39
7.3.210.0090.00916.39
7.3.200.0000.01516.49
7.3.190.0100.00616.39
7.3.180.0120.00616.64
7.3.170.0000.01716.46
7.3.160.0110.00716.49
7.2.330.0090.01116.82
7.2.320.0060.01216.79
7.2.310.0060.01116.80
7.2.300.0110.00716.77
7.2.290.0070.01016.71
7.2.60.0040.01216.63
7.1.200.0070.00715.83
7.1.100.0740.01016.22
7.1.70.0080.00617.01
7.1.60.0330.01733.23
7.1.50.0330.01732.99
7.1.40.0330.01332.70
7.1.30.0470.01032.83
7.1.20.0470.02032.75
7.1.10.0400.01014.71
7.1.00.0200.01315.07
7.0.200.0300.00714.91
7.0.190.0200.01315.08
7.0.180.0300.00714.46
7.0.170.0370.00714.45
7.0.160.0370.01014.39
7.0.150.0400.00314.52
7.0.140.0230.01714.62
7.0.130.0230.01014.84
7.0.120.0230.01014.70
7.0.110.0270.00714.50
7.0.100.0230.01014.53
7.0.90.0300.00714.56
7.0.80.0330.00314.66
7.0.70.0330.00314.63
7.0.60.0270.00714.36
7.0.50.0270.00714.54
7.0.40.0230.01714.70
7.0.30.0270.01014.82
7.0.20.0300.00714.73
7.0.10.0330.00314.55
7.0.00.0300.00714.58

preferences:
37.07 ms | 400 KiB | 5 Q