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.0170.00318.68
8.3.50.0140.00016.49
8.3.40.0090.00618.88
8.3.30.0130.00318.85
8.3.20.0040.00420.20
8.3.10.0050.00321.73
8.3.00.0040.00420.93
8.2.180.0070.00718.55
8.2.170.0150.00022.96
8.2.160.0090.00521.96
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0040.00422.14
8.2.120.0040.00426.35
8.2.110.0100.00020.84
8.2.100.0040.00817.97
8.2.90.0080.00019.00
8.2.80.0030.00517.97
8.2.70.0000.00917.50
8.2.60.0040.00418.16
8.2.50.0040.00418.16
8.2.40.0000.00922.13
8.2.30.0040.00421.02
8.2.20.0040.00418.01
8.2.10.0030.00618.06
8.2.00.0040.00418.12
8.1.280.0130.00325.92
8.1.270.0040.00422.20
8.1.260.0050.00326.35
8.1.250.0090.00328.09
8.1.240.0030.00719.20
8.1.230.0090.00322.15
8.1.220.0090.00017.74
8.1.210.0060.00318.77
8.1.200.0030.00617.36
8.1.190.0030.00617.23
8.1.180.0000.00718.10
8.1.170.0030.00618.46
8.1.160.0070.00019.07
8.1.150.0050.00218.81
8.1.140.0040.00419.54
8.1.130.0000.00718.88
8.1.120.0040.00717.50
8.1.110.0000.00817.39
8.1.100.0040.00417.48
8.1.90.0000.00717.48
8.1.80.0000.00717.50
8.1.70.0050.00217.48
8.1.60.0030.00617.58
8.1.50.0080.00017.42
8.1.40.0030.00517.52
8.1.30.0000.00817.55
8.1.20.0070.00017.68
8.1.10.0030.00617.63
8.1.00.0070.00017.49
8.0.300.0070.00018.77
8.0.290.0050.00316.59
8.0.280.0030.00518.39
8.0.270.0000.00717.20
8.0.260.0030.00316.84
8.0.250.0000.00716.98
8.0.240.0040.00416.77
8.0.230.0030.00516.95
8.0.220.0050.00216.93
8.0.210.0070.00016.92
8.0.200.0060.00016.96
8.0.190.0040.00816.94
8.0.180.0060.00316.91
8.0.170.0070.00016.84
8.0.160.0030.00516.90
8.0.150.0050.00216.87
8.0.140.0040.00416.75
8.0.130.0070.00013.36
8.0.120.0070.00016.91
8.0.110.0040.00416.89
8.0.100.0050.00316.89
8.0.90.0000.00716.73
8.0.80.0090.01616.89
8.0.70.0050.00216.96
8.0.60.0000.00716.97
8.0.50.0040.00416.76
8.0.30.0070.01116.89
8.0.20.0100.01017.40
8.0.10.0070.00016.90
8.0.00.0120.00816.71
7.4.330.0030.00315.55
7.4.320.0060.00016.51
7.4.300.0000.00616.66
7.4.290.0000.00916.54
7.4.280.0000.00816.50
7.4.270.0030.00316.47
7.4.260.0030.00416.61
7.4.250.0070.00016.59
7.4.240.0030.00416.63
7.4.230.0030.00316.41
7.4.220.0150.01516.62
7.4.210.0080.00816.51
7.4.200.0000.00716.42
7.4.160.0120.00816.55
7.4.150.0130.01017.40
7.4.140.0160.00417.86
7.4.130.0100.01216.59
7.4.120.0080.01416.61
7.4.110.0100.00716.64
7.4.100.0070.01416.61
7.4.90.0070.01116.37
7.4.80.0070.01019.39
7.4.70.0100.00716.61
7.4.60.0030.01416.50
7.4.50.0040.01216.53
7.4.40.0080.00816.41
7.4.30.0100.01016.60
7.4.00.0030.01315.15
7.3.330.0000.00613.22
7.3.320.0030.00313.26
7.3.310.0030.00316.30
7.3.300.0000.00716.26
7.3.290.0040.01016.35
7.3.280.0080.00916.33
7.3.270.0160.01017.40
7.3.260.0150.00716.32
7.3.250.0100.01116.37
7.3.240.0120.00616.36
7.3.230.0130.00716.58
7.3.210.0120.00616.32
7.3.200.0070.01316.40
7.3.190.0060.01116.38
7.3.180.0100.00716.49
7.3.170.0080.00816.34
7.3.160.0150.00416.26
7.2.330.0090.01216.49
7.2.320.0110.00716.40
7.2.310.0070.01016.50
7.2.300.0090.00916.34
7.2.290.0120.00616.82
7.2.60.0040.01117.10
7.2.00.0070.00419.39
7.1.200.0030.00915.89
7.1.100.0060.01017.81
7.1.70.0000.01016.81
7.1.60.0130.01733.25
7.1.50.0200.01033.21
7.1.40.0330.01332.64
7.1.30.0800.02032.93
7.1.20.0570.01032.53
7.1.10.0470.01014.95
7.1.00.0430.01314.88
7.0.200.0470.01315.00
7.0.190.0500.00715.04
7.0.180.0070.00714.39
7.0.170.0530.01014.51
7.0.160.0430.01314.54
7.0.150.0600.01014.43
7.0.140.0500.01014.46
7.0.130.0070.01014.64
7.0.120.0500.00314.77
7.0.110.0470.00714.66
7.0.100.0470.00714.30
7.0.90.0500.00714.19
7.0.80.0270.01314.45
7.0.70.0170.01714.61
7.0.60.0470.01714.35
7.0.50.0070.01714.33
7.0.40.0800.01314.74
7.0.30.0270.00714.57
7.0.20.0030.01714.84
7.0.10.0830.01014.52
7.0.00.1300.01314.66

preferences:
51.93 ms | 400 KiB | 5 Q