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': 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; 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.0150.00018.56
8.3.50.0090.01216.63
8.3.40.0050.01018.65
8.3.30.0090.00618.73
8.3.20.0000.00820.23
8.3.10.0060.00321.90
8.3.00.0030.00520.84
8.2.180.0120.00618.25
8.2.170.0110.00722.96
8.2.160.0140.00022.09
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0040.00422.13
8.2.120.0040.00426.35
8.2.110.0030.00620.35
8.2.100.0120.00017.84
8.2.90.0050.00319.22
8.2.80.0040.00417.97
8.2.70.0030.00517.48
8.2.60.0050.00318.04
8.2.50.0000.00818.10
8.2.40.0030.00522.29
8.2.30.0040.00421.09
8.2.20.0000.00818.14
8.2.10.0000.00818.05
8.2.00.0000.00718.13
8.1.280.0120.00925.92
8.1.270.0100.00023.84
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0060.00320.75
8.1.230.0060.00619.10
8.1.220.0030.00617.74
8.1.210.0030.00518.77
8.1.200.0070.00317.36
8.1.190.0040.00417.23
8.1.180.0040.00418.10
8.1.170.0030.00518.65
8.1.160.0080.00018.93
8.1.150.0040.00418.95
8.1.140.0040.00419.50
8.1.130.0030.00318.95
8.1.120.0000.00817.44
8.1.110.0040.00417.52
8.1.100.0050.00317.47
8.1.90.0050.00317.48
8.1.80.0030.00617.52
8.1.70.0030.00617.45
8.1.60.0000.00817.64
8.1.50.0000.00817.54
8.1.40.0060.00317.56
8.1.30.0040.00417.66
8.1.20.0000.00817.63
8.1.10.0040.00417.59
8.1.00.0050.00317.50
8.0.300.0000.00718.77
8.0.290.0000.00716.75
8.0.280.0000.00718.45
8.0.270.0080.00017.27
8.0.260.0000.00716.82
8.0.250.0030.00317.03
8.0.240.0080.00016.82
8.0.230.0040.00416.97
8.0.220.0040.00416.96
8.0.210.0000.00716.98
8.0.200.0060.00017.00
8.0.190.0040.00417.08
8.0.180.0090.00016.98
8.0.170.0040.00416.97
8.0.160.0040.00416.87
8.0.150.0000.00816.93
8.0.140.0050.00316.86
8.0.130.0030.00613.31
8.0.120.0050.00316.94
8.0.110.0040.00416.96
8.0.100.0000.00716.85
8.0.90.0080.00016.93
8.0.80.0140.00417.02
8.0.70.0000.00817.01
8.0.60.0070.00016.84
8.0.50.0050.00316.91
8.0.30.0130.00817.17
8.0.20.0140.00717.40
8.0.10.0040.00417.14
8.0.00.0100.01016.93
7.4.330.0000.00515.55
7.4.320.0030.00316.61
7.4.300.0030.00316.43
7.4.290.0040.00416.62
7.4.280.0080.00016.51
7.4.270.0030.00316.63
7.4.260.0030.00316.48
7.4.250.0000.00716.63
7.4.240.0000.00816.63
7.4.230.0000.00716.70
7.4.220.0100.01716.55
7.4.210.0060.01516.59
7.4.200.0040.00416.43
7.4.160.0140.00316.62
7.4.150.0120.00917.40
7.4.140.0110.00817.86
7.4.130.0090.01216.60
7.4.120.0070.01216.49
7.4.110.0100.00716.48
7.4.100.0140.00816.68
7.4.90.0090.00916.43
7.4.80.0060.01219.39
7.4.70.0100.00816.47
7.4.60.0030.01616.55
7.4.50.0120.00316.60
7.4.40.0000.01716.64
7.4.30.0140.00316.58
7.4.00.0060.00615.16
7.3.330.0030.00313.25
7.3.320.0000.00613.32
7.3.310.0090.00016.27
7.3.300.0030.00316.39
7.3.290.0110.00416.37
7.3.280.0100.00716.38
7.3.270.0160.00317.40
7.3.260.0110.00816.47
7.3.250.0090.01016.37
7.3.240.0100.00816.45
7.3.230.0120.00616.65
7.3.210.0110.00716.46
7.3.200.0000.01716.43
7.3.190.0060.01216.40
7.3.180.0090.00616.46
7.3.170.0110.00616.54
7.3.160.0000.01616.41
7.2.330.0000.01816.64
7.2.320.0070.01116.77
7.2.310.0070.01016.54
7.2.300.0100.00716.71
7.2.290.0080.01116.82
7.2.60.0120.00816.98
7.1.200.0030.00615.84
7.1.100.0030.01318.32
7.1.70.0040.00417.19
7.1.60.0330.01333.25
7.1.50.0330.01732.96
7.1.40.0170.01332.41
7.1.30.0430.00732.93
7.1.20.0800.02032.93
7.1.10.0000.01314.64
7.1.00.0330.01714.79
7.0.200.0070.00714.92
7.0.190.0070.01015.03
7.0.180.0200.01314.41
7.0.170.0470.00714.40
7.0.160.0400.01314.48
7.0.150.0200.01314.45
7.0.140.0370.00714.52
7.0.130.0530.01314.64
7.0.120.0300.00714.47
7.0.110.0270.01014.47
7.0.100.0470.00714.45
7.0.90.0370.01714.57
7.0.80.0330.00014.53
7.0.70.0270.01314.47
7.0.60.0300.00714.07
7.0.50.0100.01014.48
7.0.40.0300.01014.61
7.0.30.0330.01314.45
7.0.20.0400.00014.63
7.0.10.0330.00714.59
7.0.00.0270.01014.67

preferences:
56.85 ms | 400 KiB | 5 Q