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.70.0070.01716.75
8.3.60.0070.01116.75
8.3.50.0200.00816.54
8.3.40.0130.00319.02
8.3.30.0080.00818.79
8.3.20.0040.00422.05
8.3.10.0040.00421.90
8.3.00.0050.00320.80
8.2.180.0110.00418.41
8.2.170.0120.00322.96
8.2.160.0080.00622.15
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0050.00322.20
8.2.120.0040.00426.35
8.2.110.0070.00321.95
8.2.100.0070.00417.91
8.2.90.0080.00019.17
8.2.80.0000.00818.05
8.2.70.0030.00517.62
8.2.60.0040.00418.04
8.2.50.0000.00918.10
8.2.40.0080.00022.23
8.2.30.0040.00421.09
8.2.20.0040.00418.22
8.2.10.0080.00018.02
8.2.00.0040.00418.24
8.1.280.0120.00425.92
8.1.270.0040.01122.14
8.1.260.0040.00426.35
8.1.250.0060.01028.09
8.1.240.0030.00623.83
8.1.230.0030.01022.20
8.1.220.0000.01017.76
8.1.210.0050.00318.77
8.1.200.0030.00617.23
8.1.190.0060.00317.13
8.1.180.0040.00418.10
8.1.170.0000.00818.50
8.1.160.0040.00419.03
8.1.150.0000.00718.90
8.1.140.0050.00319.53
8.1.130.0000.00718.93
8.1.120.0040.00417.45
8.1.110.0030.00517.39
8.1.100.0030.00617.46
8.1.90.0070.00017.35
8.1.80.0000.00717.40
8.1.70.0050.00217.47
8.1.60.0060.00317.61
8.1.50.0050.00317.56
8.1.40.0030.00517.55
8.1.30.0040.00417.51
8.1.20.0080.00017.61
8.1.10.0030.00617.55
8.1.00.0040.00417.38
8.0.300.0040.00418.77
8.0.290.0030.00516.75
8.0.280.0000.00818.38
8.0.270.0070.00017.31
8.0.260.0000.00716.79
8.0.250.0000.00716.94
8.0.240.0030.00516.77
8.0.230.0000.00716.88
8.0.220.0040.00416.82
8.0.210.0030.00316.82
8.0.200.0000.00716.96
8.0.190.0040.00816.93
8.0.180.0040.00416.92
8.0.170.0030.00317.00
8.0.160.0040.00416.88
8.0.150.0080.00016.80
8.0.140.0000.00716.86
8.0.130.0000.00713.32
8.0.120.0080.00016.84
8.0.110.0050.00216.89
8.0.100.0070.00016.75
8.0.90.0000.00716.97
8.0.80.0060.00916.96
8.0.70.0070.00016.85
8.0.60.0000.00716.79
8.0.50.0000.00716.84
8.0.30.0140.00717.05
8.0.20.0120.00917.40
8.0.10.0040.00416.88
8.0.00.0080.01716.79
7.4.330.0030.00315.55
7.4.320.0000.00616.51
7.4.300.0030.00316.57
7.4.290.0070.00316.51
7.4.280.0080.00016.54
7.4.270.0000.00716.54
7.4.260.0070.00016.50
7.4.250.0000.00716.49
7.4.240.0000.00716.60
7.4.230.0030.00316.59
7.4.220.0090.01216.65
7.4.210.0170.00316.63
7.4.200.0040.00416.41
7.4.160.0100.00616.60
7.4.150.0170.00317.40
7.4.140.0120.00717.86
7.4.130.0060.01516.43
7.4.120.0090.01016.59
7.4.110.0100.00716.53
7.4.100.0100.01016.71
7.4.90.0130.01016.47
7.4.80.0140.00319.39
7.4.70.0090.00916.64
7.4.60.0070.01016.52
7.4.50.0070.01016.54
7.4.40.0100.00716.71
7.4.30.0070.01016.50
7.4.10.0100.00314.90
7.4.00.0060.00814.90
7.3.330.0030.00313.16
7.3.320.0030.00313.18
7.3.310.0040.00416.41
7.3.300.0000.00716.36
7.3.290.0050.01116.31
7.3.280.0080.00816.36
7.3.270.0090.00917.40
7.3.260.0110.00716.45
7.3.250.0080.01016.43
7.3.240.0140.00716.45
7.3.230.0030.01316.61
7.3.210.0090.00816.49
7.3.200.0070.01416.50
7.3.190.0130.00316.58
7.3.180.0070.01016.63
7.3.170.0170.00016.57
7.3.160.0090.00616.61
7.3.130.0100.00714.55
7.3.120.0060.00915.07
7.3.110.0070.01014.70
7.3.100.0060.00614.94
7.3.90.0110.00714.59
7.3.80.0040.00814.90
7.3.70.0030.01014.88
7.3.60.0000.01014.54
7.3.50.0060.01014.73
7.3.40.0060.00314.83
7.3.30.0060.00614.55
7.3.20.0040.00816.54
7.3.10.0060.00616.61
7.3.00.0070.00716.65
7.2.330.0130.00516.57
7.2.320.0150.00316.59
7.2.310.0070.01116.62
7.2.300.0040.01516.41
7.2.290.0060.01116.46
7.2.260.0070.01015.03
7.2.250.0070.00615.02
7.2.240.0030.00915.27
7.2.230.0110.00815.32
7.2.220.0100.00715.29
7.2.210.0040.01215.04
7.2.200.0090.00615.02
7.2.190.0030.00714.98
7.2.180.0080.00415.17
7.2.170.0080.00815.00
7.2.160.0070.01115.32
7.2.150.0040.01216.87
7.2.140.0000.01617.02
7.2.130.0090.00616.73
7.2.120.0040.01417.02
7.2.110.0030.00916.77
7.2.100.0150.00316.59
7.2.90.0060.00617.02
7.2.80.0080.00816.93
7.2.70.0040.01116.82
7.2.60.0070.00516.74
7.2.50.0070.00317.06
7.2.40.0040.01117.06
7.2.30.0000.01317.04
7.2.20.0000.01516.96
7.2.10.0030.01017.03
7.2.00.0030.01018.21
7.1.330.0080.00415.84
7.1.320.0090.00615.97
7.1.310.0100.00015.95
7.1.300.0030.00915.79
7.1.290.0060.01015.77
7.1.280.0030.00715.52
7.1.270.0120.00315.66
7.1.260.0000.01215.66
7.1.250.0070.00716.05
7.1.240.0030.00715.93
7.1.230.0100.00315.54
7.1.220.0000.01515.91
7.1.210.0030.01315.96
7.1.200.0050.00915.70
7.1.190.0070.00715.71
7.1.180.0050.00315.86
7.1.170.0080.00415.93
7.1.160.0060.00915.88
7.1.150.0000.01315.85
7.1.140.0030.00915.82
7.1.130.0000.01515.46
7.1.120.0030.00715.96
7.1.110.0080.00616.00
7.1.100.0100.00317.10
7.1.90.0000.01215.80
7.1.80.0040.01115.71
7.1.70.0040.00816.56
7.1.60.0370.01224.58
7.1.50.0390.01024.28
7.1.40.0310.01224.22
7.1.30.0400.00624.37
7.1.20.0320.00624.27
7.1.10.0230.01415.38
7.1.00.0250.00915.31
7.0.330.0090.00315.46
7.0.320.0000.01715.32
7.0.310.0070.00715.27
7.0.300.0030.00715.57
7.0.290.0070.00715.22
7.0.280.0040.01215.43
7.0.270.0030.00615.52
7.0.260.0030.01015.48
7.0.250.0070.00715.27
7.0.240.0040.00715.45
7.0.230.0000.01215.41
7.0.220.0060.00915.51
7.0.210.0080.00415.45
7.0.200.0300.00915.27
7.0.190.0300.00415.19
7.0.180.0250.01215.01
7.0.170.0230.00814.85
7.0.160.0240.00914.92
7.0.150.0330.00514.83
7.0.140.0250.00815.03
7.0.130.0380.01015.00
7.0.120.0230.01015.05
7.0.110.0250.00914.87
7.0.100.0250.01014.92
7.0.90.0260.00814.90
7.0.80.0290.00914.89
7.0.70.0250.01014.89
7.0.60.0360.00514.87
7.0.50.0270.00814.93
7.0.40.0250.00713.98
7.0.30.0300.01513.90
7.0.20.0280.00614.06
7.0.10.0300.00514.03
7.0.00.0250.00514.08
5.6.400.0060.00614.67
5.6.390.0110.00414.48
5.6.380.0030.01314.72
5.6.370.0120.00314.45
5.6.360.0040.00814.36
5.6.350.0000.00914.84
5.6.340.0080.00414.30
5.6.330.0100.00014.22
5.6.320.0040.01114.06
5.6.310.0080.01114.48
5.6.300.0040.00814.40
5.6.290.0150.00314.72
5.6.280.0070.00714.45
5.6.270.0030.00814.33
5.6.260.0090.00314.68
5.6.250.0000.01214.29
5.6.240.0090.00614.40
5.6.230.0030.00914.30
5.6.220.0060.00314.28
5.6.210.0030.00614.49
5.6.200.0030.00914.31
5.6.190.0040.00714.41
5.6.180.0060.00314.37
5.6.170.0070.00714.76
5.6.160.0060.00314.50
5.6.150.0030.01014.23
5.6.140.0040.01114.54
5.6.130.0030.01114.63
5.6.120.0000.00914.26
5.6.110.0000.00914.57
5.6.100.0000.00914.14
5.6.90.0080.00314.65
5.6.80.0030.00914.68
5.6.70.0040.00814.49
5.6.60.0090.00014.58
5.6.50.0040.00814.51
5.6.40.0100.00014.21
5.6.30.0060.00614.36
5.6.20.0080.00414.14
5.6.10.0070.00714.16
5.6.00.0040.00713.98

preferences:
39.98 ms | 401 KiB | 5 Q