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]; } } $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.00416.88
8.3.50.0150.00016.75
8.3.40.0040.01118.89
8.3.30.0040.01218.68
8.3.20.0080.00020.20
8.3.10.0030.00521.76
8.3.00.0040.00420.88
8.2.180.0080.00818.11
8.2.170.0090.00922.96
8.2.160.0110.00322.08
8.2.150.0000.00824.18
8.2.140.0000.00824.66
8.2.130.0050.00322.21
8.2.120.0080.00026.35
8.2.110.0030.00722.21
8.2.100.0080.00418.03
8.2.90.0080.00019.17
8.2.80.0060.00417.97
8.2.70.0050.00317.50
8.2.60.0030.00517.91
8.2.50.0040.00418.10
8.2.40.0040.00422.38
8.2.30.0060.00321.05
8.2.20.0080.00018.13
8.2.10.0040.00418.20
8.2.00.0040.00418.13
8.1.280.0090.00625.92
8.1.270.0080.00022.19
8.1.260.0000.00826.35
8.1.250.0050.00328.09
8.1.240.0090.00023.98
8.1.230.0030.00917.77
8.1.220.0030.00517.74
8.1.210.0030.00618.77
8.1.200.0030.00717.35
8.1.190.0030.00517.10
8.1.180.0000.00818.10
8.1.170.0000.00918.64
8.1.160.0060.00319.02
8.1.150.0030.00718.81
8.1.140.0080.00019.63
8.1.130.0000.00718.78
8.1.120.0000.00917.50
8.1.110.0000.00817.33
8.1.100.0050.00317.49
8.1.90.0030.00617.46
8.1.80.0070.00017.47
8.1.70.0030.00317.47
8.1.60.0060.00317.63
8.1.50.0030.00517.51
8.1.40.0000.00917.43
8.1.30.0030.00617.68
8.1.20.0040.00417.55
8.1.10.0040.00417.58
8.1.00.0050.00317.47
8.0.300.0040.00418.77
8.0.290.0030.00616.75
8.0.280.0000.00718.51
8.0.270.0000.00817.27
8.0.260.0000.00816.71
8.0.250.0030.00317.00
8.0.240.0040.00416.84
8.0.230.0000.00816.97
8.0.220.0000.00716.89
8.0.210.0040.00316.92
8.0.200.0060.00016.96
8.0.190.0030.00616.98
8.0.180.0040.00416.91
8.0.170.0000.00716.96
8.0.160.0040.00416.97
8.0.150.0040.00416.82
8.0.140.0050.00216.90
8.0.130.0000.00713.31
8.0.120.0040.00416.77
8.0.110.0040.00416.80
8.0.100.0000.00816.81
8.0.90.0040.00416.80
8.0.80.0030.01316.86
8.0.70.0000.00716.77
8.0.60.0040.00416.88
8.0.50.0000.00716.89
8.0.30.0050.01117.07
8.0.20.0110.01117.40
8.0.10.0000.00816.88
8.0.00.0060.01616.82
7.4.330.0030.00315.55
7.4.320.0060.00316.54
7.4.300.0000.00616.53
7.4.290.0070.00316.46
7.4.280.0050.00516.46
7.4.270.0080.00016.61
7.4.260.0070.00016.50
7.4.250.0000.00716.57
7.4.240.0000.00716.55
7.4.230.0030.00316.71
7.4.220.0110.00716.49
7.4.210.0040.01116.52
7.4.200.0080.00016.63
7.4.160.0090.01016.55
7.4.150.0140.00717.40
7.4.140.0100.01017.86
7.4.130.0120.01216.46
7.4.120.0120.01016.53
7.4.110.0190.00316.60
7.4.100.0100.00716.43
7.4.90.0030.01316.66
7.4.80.0070.01119.39
7.4.70.0070.01016.46
7.4.60.0100.00816.46
7.4.50.0060.00316.50
7.4.40.0070.01016.68
7.4.30.0030.01416.49
7.4.10.0090.00914.73
7.4.00.0060.01014.96
7.3.330.0070.00013.24
7.3.320.0050.00013.09
7.3.310.0070.00016.33
7.3.300.0070.00016.42
7.3.290.0130.00316.35
7.3.280.0080.00916.35
7.3.270.0110.00717.40
7.3.260.0120.00916.52
7.3.250.0120.00816.49
7.3.240.0120.00716.58
7.3.230.0170.00816.55
7.3.210.0130.00616.30
7.3.200.0090.00816.33
7.3.190.0080.00816.45
7.3.180.0090.01216.67
7.3.170.0080.00816.49
7.3.160.0150.00416.39
7.3.130.0030.01314.80
7.3.120.0100.00614.94
7.3.110.0020.01515.06
7.3.100.0080.00714.98
7.3.90.0090.00714.96
7.3.80.0060.00614.88
7.3.70.0020.01114.80
7.3.60.0050.00615.02
7.3.50.0060.01014.93
7.3.40.0070.00514.90
7.3.30.0050.00914.99
7.3.20.0050.00816.59
7.3.10.0080.00616.54
7.3.00.0100.00516.56
7.2.330.0130.00716.60
7.2.320.0120.02116.55
7.2.310.0060.01516.79
7.2.300.0080.00916.45
7.2.290.0050.01116.35
7.2.260.0000.01714.91
7.2.250.0080.00915.23
7.2.240.0080.01014.99
7.2.230.0060.00615.13
7.2.220.0050.00815.14
7.2.210.0040.00815.06
7.2.200.0040.00915.11
7.2.190.0070.00715.07
7.2.180.0110.00215.12
7.2.170.0030.00915.18
7.2.160.0030.00615.14
7.2.150.0070.00716.82
7.2.140.0060.00616.92
7.2.130.0030.01016.90
7.2.120.0090.00016.86
7.2.110.0000.01116.90
7.2.100.0040.01116.86
7.2.90.0000.01217.11
7.2.80.0000.01116.80
7.2.70.0070.00716.96
7.2.60.0070.00916.96
7.2.50.0040.01517.18
7.2.40.0040.00717.00
7.2.30.0090.00617.06
7.2.20.0110.00416.79
7.2.10.0040.01117.08
7.2.00.0040.01217.81
7.1.330.0020.01115.79
7.1.320.0020.01215.84
7.1.310.0080.00415.79
7.1.300.0050.00915.75
7.1.290.0050.00615.80
7.1.280.0030.01015.81
7.1.270.0090.00515.61
7.1.260.0080.00515.78
7.1.250.0030.00915.61
7.1.240.0060.00715.54
7.1.230.0030.00615.73
7.1.220.0070.01115.74
7.1.210.0070.01016.01
7.1.200.0060.00615.94
7.1.190.0090.00615.73
7.1.180.0070.00715.54
7.1.170.0100.00715.98
7.1.160.0100.00015.82
7.1.150.0060.00615.77
7.1.140.0040.00815.60
7.1.130.0060.00615.91
7.1.120.0120.00415.66
7.1.110.0100.00715.50
7.1.100.0050.00716.92
7.1.90.0040.00415.93
7.1.80.0090.00615.89
7.1.70.0060.00516.61
7.1.60.0330.00824.35
7.1.50.0330.01124.58
7.1.40.0270.00724.29
7.1.30.0270.00724.27
7.1.20.0280.01024.37
7.1.10.0340.00715.20
7.1.00.0220.00915.38
7.0.330.0060.00315.35
7.0.320.0060.00915.45
7.0.310.0060.00615.21
7.0.300.0000.01715.39
7.0.290.0030.00915.32
7.0.280.0030.01415.20
7.0.270.0080.00415.37
7.0.260.0000.01515.36
7.0.250.0090.00315.50
7.0.240.0000.01115.66
7.0.230.0000.00815.48
7.0.220.0040.00715.53
7.0.210.0130.00315.23
7.0.200.0180.00815.35
7.0.190.0630.00815.26
7.0.180.0160.01014.79
7.0.170.0250.00514.93
7.0.160.0210.00514.91
7.0.150.0230.00415.04
7.0.140.0220.00914.96
7.0.130.0230.00815.06
7.0.120.0150.01115.26
7.0.110.0220.00714.87
7.0.100.0200.00714.96
7.0.90.0210.00714.90
7.0.80.0230.00415.03
7.0.70.0180.01114.78
7.0.60.0240.00514.98
7.0.50.0180.01315.20
7.0.40.0180.00914.14
7.0.30.0210.00514.02
7.0.20.0240.00613.98
7.0.10.0240.00514.12
7.0.00.0260.00314.10
5.6.400.0030.00614.72
5.6.390.0140.00014.41
5.6.380.0070.00714.40
5.6.370.0000.01114.83
5.6.360.0070.01014.38
5.6.350.0000.00914.50
5.6.340.0090.00314.47
5.6.330.0030.00914.19
5.6.320.0100.00314.70
5.6.310.0100.00314.83
5.6.300.0150.00414.55
5.6.290.0040.01214.35
5.6.280.0100.00314.40
5.6.270.0060.00614.10
5.6.260.0030.01014.56
5.6.250.0100.00714.33
5.6.240.0040.00814.43
5.6.230.0030.01014.18
5.6.220.0040.00814.53
5.6.210.0000.01814.44
5.6.200.0110.00714.29
5.6.190.0110.00414.31
5.6.180.0000.01814.70
5.6.170.0140.00014.35
5.6.160.0030.00614.18
5.6.150.0090.00614.46
5.6.140.0070.00314.44
5.6.130.0030.00914.64
5.6.120.0040.00414.34
5.6.110.0110.00414.23
5.6.100.0060.00614.16
5.6.90.0110.00414.27
5.6.80.0060.00314.49
5.6.70.0030.00914.45
5.6.60.0070.00414.07
5.6.50.0060.01014.52
5.6.40.0030.00714.22
5.6.30.0040.01114.23
5.6.20.0030.00714.45
5.6.10.0070.00714.12
5.6.00.0030.01014.34

preferences:
54.79 ms | 400 KiB | 5 Q