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]; } } 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) { continue(2); } } $or = true; break; } 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; if (sizeof($out) === $query_limit) { break; } } 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.0090.00618.56
8.3.50.0130.01016.30
8.3.40.0080.00818.79
8.3.30.0120.00318.82
8.3.20.0070.00020.35
8.3.10.0050.00321.95
8.3.00.0040.00420.90
8.2.180.0090.00918.36
8.2.170.0120.00622.96
8.2.160.0070.00722.12
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0030.00522.25
8.2.120.0070.00026.35
8.2.110.0040.00720.43
8.2.100.0080.00417.78
8.2.90.0030.00619.05
8.2.80.0040.00417.97
8.2.70.0040.00417.75
8.2.60.0030.00617.93
8.2.50.0030.00518.10
8.2.40.0000.00821.98
8.2.30.0000.00820.95
8.2.20.0000.00718.10
8.2.10.0040.00418.05
8.2.00.0040.00418.01
8.1.280.0060.00925.92
8.1.270.0040.00422.02
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0070.00320.90
8.1.230.0080.00319.15
8.1.220.0080.00017.74
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0060.00317.23
8.1.180.0040.00418.10
8.1.170.0060.00318.67
8.1.160.0040.00418.97
8.1.150.0060.00320.78
8.1.140.0020.00519.50
8.1.130.0030.00318.97
8.1.120.0070.00317.39
8.1.110.0040.00417.49
8.1.100.0000.00817.44
8.1.90.0040.00417.43
8.1.80.0000.00817.36
8.1.70.0030.00317.49
8.1.60.0000.00817.50
8.1.50.0050.00317.56
8.1.40.0050.00317.59
8.1.30.0040.00417.68
8.1.20.0070.00017.55
8.1.10.0000.00817.50
8.1.00.0000.00817.57
8.0.300.0000.00818.77
8.0.290.0000.00716.75
8.0.280.0000.00718.38
8.0.270.0000.00717.19
8.0.260.0030.00316.80
8.0.250.0000.00716.93
8.0.240.0040.00416.94
8.0.230.0030.00317.04
8.0.220.0030.00317.03
8.0.210.0040.00416.95
8.0.200.0000.00817.01
8.0.190.0040.00416.99
8.0.180.0040.00816.89
8.0.170.0040.00416.97
8.0.160.0040.00417.06
8.0.150.0040.00416.81
8.0.140.0000.00716.86
8.0.130.0050.00313.30
8.0.120.0000.00716.76
8.0.110.0040.00417.02
8.0.100.0040.00417.00
8.0.90.0040.00417.04
8.0.80.0040.01116.99
8.0.70.0040.00416.86
8.0.60.0000.00716.80
8.0.50.0040.00416.82
8.0.30.0060.01417.06
8.0.20.0180.01017.40
8.0.10.0030.00317.21
8.0.00.0120.00616.75
7.4.330.0000.00515.55
7.4.320.0030.00316.70
7.4.300.0000.00716.42
7.4.290.0030.00316.65
7.4.280.0070.00016.56
7.4.270.0030.00316.55
7.4.260.0080.00016.62
7.4.250.0030.00516.50
7.4.240.0040.00416.64
7.4.230.0030.00316.64
7.4.220.0140.00416.44
7.4.210.0040.01416.51
7.4.200.0050.00216.36
7.4.160.0090.00816.56
7.4.150.0070.01117.40
7.4.140.0100.01217.86
7.4.130.0130.00916.64
7.4.120.0090.01216.60
7.4.110.0090.00916.74
7.4.100.0060.01316.53
7.4.90.0070.01016.46
7.4.80.0070.01019.39
7.4.70.0100.00616.43
7.4.60.0040.01516.63
7.4.50.0060.00616.70
7.4.40.0100.00716.56
7.4.30.0140.00416.76
7.4.00.0080.01015.10
7.3.330.0000.00513.25
7.3.320.0000.00613.32
7.3.310.0040.00416.28
7.3.300.0070.00016.43
7.3.290.0070.01016.41
7.3.280.0100.00916.40
7.3.270.0060.01217.40
7.3.260.0100.00716.47
7.3.250.0110.00716.38
7.3.240.0110.00716.53
7.3.230.0030.01416.48
7.3.210.0080.00816.52
7.3.200.0100.00616.48
7.3.190.0060.01116.43
7.3.180.0110.00616.43
7.3.170.0030.01316.53
7.3.160.0060.01016.51
7.3.120.0160.00014.93
7.3.110.0100.01015.01
7.3.100.0070.01115.09
7.3.90.0000.01415.05
7.3.80.0070.00714.94
7.3.70.0060.00614.80
7.3.60.0090.00614.74
7.3.50.0090.00314.82
7.3.40.0040.01214.70
7.3.30.0030.01414.84
7.3.20.0150.00016.70
7.3.10.0120.00616.73
7.3.00.0040.00916.85
7.2.330.0090.00916.52
7.2.320.0080.01516.49
7.2.310.0130.00316.81
7.2.300.0080.00816.77
7.2.290.0170.00016.71
7.2.250.0030.01415.04
7.2.240.0130.00615.00
7.2.230.0070.01015.32
7.2.220.0030.00614.98
7.2.210.0070.01115.09
7.2.200.0040.00715.21
7.2.190.0080.00015.00
7.2.180.0100.00715.11
7.2.170.0110.00015.00
7.2.160.0030.01014.87
7.2.150.0040.01117.02
7.2.140.0040.01416.95
7.2.130.0090.00916.68
7.2.120.0040.00716.79
7.2.110.0100.00316.92
7.2.100.0060.00916.93
7.2.90.0150.00317.17
7.2.80.0030.01216.62
7.2.70.0100.00716.76
7.2.60.0070.00516.97
7.2.50.0120.00616.88
7.2.40.0070.00817.11
7.2.30.0040.01116.96
7.2.20.0050.00516.91
7.2.10.0070.00716.84
7.2.00.0060.01118.03
7.1.330.0120.00316.05
7.1.320.0040.00815.70
7.1.310.0080.00615.73
7.1.300.0000.01315.69
7.1.290.0070.00715.87
7.1.280.0000.01415.89
7.1.270.0070.00715.67
7.1.260.0060.01215.72
7.1.250.0060.01216.02
7.1.240.0000.01415.91
7.1.230.0040.01115.96
7.1.220.0070.00715.55
7.1.210.0060.00915.81
7.1.200.0090.00515.91
7.1.190.0100.00715.57
7.1.180.0060.00915.88
7.1.170.0030.01415.87
7.1.160.0070.00415.72
7.1.150.0030.01015.63
7.1.140.0030.00915.95
7.1.130.0030.01415.94
7.1.120.0060.00615.60
7.1.110.0070.00715.94
7.1.100.0050.00816.91
7.1.90.0030.01015.85
7.1.80.0130.00315.83
7.1.70.0080.00816.38
7.1.60.0740.01224.58
7.1.50.0310.01024.29
7.1.40.0240.01024.26
7.1.30.0280.00524.29
7.1.20.0280.01024.21
7.1.10.0180.01115.28
7.1.00.0270.01015.31
7.0.330.0000.01715.46
7.0.320.0040.00415.48
7.0.310.0080.00415.64
7.0.300.0030.00615.45
7.0.290.0030.00615.36
7.0.280.0030.01015.41
7.0.270.0000.00915.32
7.0.260.0000.01215.64
7.0.250.0030.00915.36
7.0.240.0060.00615.42
7.0.230.0080.00415.50
7.0.220.0060.00615.51
7.0.210.0090.00315.52
7.0.200.0240.00515.31
7.0.190.0250.00915.15
7.0.180.0160.00814.98
7.0.170.0200.00614.88
7.0.160.0230.00914.96
7.0.150.0230.00514.93
7.0.140.0310.00814.90
7.0.130.0170.00815.13
7.0.120.0210.00515.18
7.0.110.0170.00715.02
7.0.100.0220.00514.92
7.0.90.0200.00914.96
7.0.80.0180.00814.79
7.0.70.0180.01315.11
7.0.60.0200.00914.81
7.0.50.0290.01014.95
7.0.40.0260.00814.04
7.0.30.0250.01014.00
7.0.20.0180.01114.07
7.0.10.0180.01214.09
7.0.00.0220.00714.06
5.6.400.0060.01214.25
5.6.390.0060.00814.12
5.6.380.0040.01114.49
5.6.370.0090.00614.38
5.6.360.0040.00714.27
5.6.350.0090.00614.66
5.6.340.0000.00914.59
5.6.330.0060.00614.29
5.6.320.0040.01114.37
5.6.310.0060.00914.70
5.6.300.0060.00914.68
5.6.290.0060.00614.66
5.6.280.0060.00314.17
5.6.270.0000.00814.51
5.6.260.0030.01314.27
5.6.250.0070.00714.52
5.6.240.0000.01614.18
5.6.230.0060.01314.66
5.6.220.0040.00414.40
5.6.210.0060.00614.43
5.6.200.0040.00414.43
5.6.190.0140.00414.62
5.6.180.0100.00314.61
5.6.170.0030.00714.52
5.6.160.0040.01114.39
5.6.150.0000.01614.39
5.6.140.0100.00714.27
5.6.130.0130.00314.52
5.6.120.0030.00814.72
5.6.110.0030.00914.21
5.6.100.0040.01114.41
5.6.90.0040.01114.58
5.6.80.0070.00714.57
5.6.70.0030.01014.55
5.6.60.0070.00314.45
5.6.50.0090.00614.51
5.6.40.0100.00714.48
5.6.30.0100.00714.36
5.6.20.0060.00914.33
5.6.10.0000.01214.50
5.6.00.0000.01414.40

preferences:
49.29 ms | 401 KiB | 5 Q