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 (!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) { echo 1; continue(2); } } echo 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.0150.00318.43
8.3.50.0110.01116.60
8.3.40.0150.00018.85
8.3.30.0080.00818.66
8.3.20.0050.00320.31
8.3.10.0080.00021.90
8.3.00.0040.00720.75
8.2.180.0110.00318.31
8.2.170.0060.01222.96
8.2.160.0070.00722.08
8.2.150.0030.00524.18
8.2.140.0080.00024.66
8.2.130.0080.00022.06
8.2.120.0080.00026.35
8.2.110.0060.00322.08
8.2.100.0040.00818.03
8.2.90.0040.00419.17
8.2.80.0040.00417.97
8.2.70.0040.00417.63
8.2.60.0000.00818.05
8.2.50.0040.00418.10
8.2.40.0040.00422.07
8.2.30.0000.00821.04
8.2.20.0040.00418.13
8.2.10.0000.00818.01
8.2.00.0040.00418.01
8.1.280.0110.00425.92
8.1.270.0080.00021.98
8.1.260.0000.00826.35
8.1.250.0090.00928.09
8.1.240.0000.00923.96
8.1.230.0040.00822.20
8.1.220.0040.00417.79
8.1.210.0040.00418.77
8.1.200.0060.00317.23
8.1.190.0030.00617.22
8.1.180.0040.00418.10
8.1.170.0060.00318.56
8.1.160.0000.00719.06
8.1.150.0000.00718.84
8.1.140.0050.00219.55
8.1.130.0000.00718.94
8.1.120.0070.00317.45
8.1.110.0000.00717.47
8.1.100.0030.00617.40
8.1.90.0000.00817.52
8.1.80.0000.00817.45
8.1.70.0040.00417.51
8.1.60.0060.00317.65
8.1.50.0000.00817.56
8.1.40.0000.00817.57
8.1.30.0040.00417.61
8.1.20.0060.00317.68
8.1.10.0000.00917.65
8.1.00.0040.00417.41
8.0.300.0030.00618.77
8.0.290.0070.00016.58
8.0.280.0030.00318.33
8.0.270.0050.00317.21
8.0.260.0000.00716.72
8.0.250.0000.00816.85
8.0.240.0000.00716.83
8.0.230.0040.00416.90
8.0.220.0070.00016.95
8.0.210.0000.00716.88
8.0.200.0000.00616.88
8.0.190.0080.00016.90
8.0.180.0070.00316.91
8.0.170.0040.00417.00
8.0.160.0000.00816.91
8.0.150.0070.00316.88
8.0.140.0040.00416.91
8.0.130.0040.00313.25
8.0.120.0000.00816.89
8.0.110.0040.00416.89
8.0.100.0050.00216.86
8.0.90.0040.00416.80
8.0.80.0110.00616.94
8.0.70.0050.00316.99
8.0.60.0070.00016.82
8.0.50.0070.00016.77
8.0.30.0120.00717.16
8.0.20.0090.01217.40
8.0.10.0000.00817.02
8.0.00.0100.01016.84
7.4.330.0030.00315.55
7.4.320.0000.00616.50
7.4.300.0030.00316.52
7.4.290.0080.00016.50
7.4.280.0030.00616.62
7.4.270.0030.00316.52
7.4.260.0040.00416.50
7.4.250.0030.00416.62
7.4.240.0000.00716.59
7.4.230.0070.00016.64
7.4.220.0160.01016.55
7.4.210.0150.00016.44
7.4.200.0000.00716.64
7.4.160.0080.01116.60
7.4.150.0190.00017.40
7.4.140.0110.00917.86
7.4.130.0210.00816.50
7.4.120.0110.01016.54
7.4.110.0070.01016.42
7.4.100.0150.00816.44
7.4.90.0070.01116.43
7.4.80.0100.00719.39
7.4.70.0090.00916.56
7.4.60.0100.01016.46
7.4.50.0040.01116.27
7.4.40.0040.01416.71
7.4.30.0130.00716.48
7.4.00.0100.00714.77
7.3.330.0030.00313.24
7.3.320.0030.00313.09
7.3.310.0000.00716.36
7.3.300.0000.00816.18
7.3.290.0070.00716.36
7.3.280.0100.00916.34
7.3.270.0080.00817.40
7.3.260.0120.00916.58
7.3.250.0150.00316.41
7.3.240.0120.01016.46
7.3.230.0070.01016.64
7.3.210.0090.00916.58
7.3.200.0070.01316.36
7.3.190.0070.01016.49
7.3.180.0140.00716.36
7.3.170.0120.00616.48
7.3.160.0040.01416.48
7.3.10.0060.00616.75
7.3.00.0070.00716.60
7.2.330.0120.01516.60
7.2.320.0120.00616.81
7.2.310.0040.01416.80
7.2.300.0180.00016.70
7.2.290.0070.01016.72
7.2.130.0000.01616.94
7.2.120.0160.00317.06
7.2.110.0140.00716.81
7.2.100.0120.01216.66
7.2.90.0080.00817.04
7.2.80.0000.01516.69
7.2.70.0090.00317.00
7.2.60.0060.00916.79
7.2.50.0030.01316.97
7.2.40.0120.00316.98
7.2.30.0060.00616.70
7.2.20.0030.01016.98
7.2.10.0090.00616.97
7.2.00.0110.00518.09
7.1.250.0040.00815.72
7.1.200.0070.00715.64
7.1.100.0060.00618.37
7.1.70.0000.01317.30
7.1.60.0300.01733.31
7.1.50.0330.01732.95
7.1.40.0400.01732.57
7.1.30.0270.02032.68
7.1.20.0500.00332.84
7.1.10.0130.01714.84
7.1.00.0200.01014.82
7.0.200.0370.01314.66
7.0.190.0200.01014.80
7.0.180.0230.01014.42
7.0.170.0200.01314.41
7.0.160.0230.01014.38
7.0.150.0170.01314.34
7.0.140.0270.01314.79
7.0.130.0200.01014.63
7.0.120.0300.01014.78
7.0.110.0230.00714.25
7.0.100.0230.01014.44
7.0.90.0200.01314.37
7.0.80.0170.01714.57
7.0.70.0200.01314.39
7.0.60.1400.01714.07
7.0.50.0270.01014.57
7.0.40.0230.01314.86
7.0.30.0230.01014.63
7.0.20.0370.01014.54
7.0.10.0200.01314.52
7.0.00.0370.01014.61

preferences:
46.26 ms | 401 KiB | 5 Q