3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ '%foo!bar', '@baz', '!bam@bat@bar', '%bee@baa', ]; $field = 'your_column'; $conditionTemplates = [ '&' => '%1$s = ?', '!' => '%1$s IS NULL OR %1$s != ?', '%' => '%1$s LIKE ?', '@' => '%1$s NOT LIKE ?', ]; $needsTrailingWildcard = ['%', '@']; foreach ($strings as $string) { $conditions = []; // reset for demo $params = []; // reset for demo preg_match_all('~([&%@!])([^&%@!]+)~', $string, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $conditions[] = sprintf($conditionTemplates[$match[1]], $field); $params[] = $match[2] . (in_array($match[1], $needsTrailingWildcard) ? '%' : ''); } var_export([implode(' AND ', $conditions), $params]); echo "\n"; }

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.0060.01518.64
8.3.50.0100.00616.75
8.3.40.0190.00019.00
8.3.30.0120.00318.84
8.3.20.0080.00024.18
8.3.10.0050.00324.66
8.3.00.0050.00226.16
8.2.180.0070.00725.92
8.2.170.0170.00319.04
8.2.160.0110.00422.96
8.2.150.0040.00425.66
8.2.140.0060.00324.66
8.2.130.0130.00626.16
8.2.120.0060.00326.35
8.2.110.0090.00022.05
8.2.100.0060.00617.97
8.2.90.0000.00818.14
8.2.80.0080.00018.34
8.2.70.0040.00417.88
8.2.60.0000.00817.88
8.2.50.0080.00017.88
8.2.40.0030.00619.60
8.2.30.0030.00518.16
8.2.20.0000.00718.09
8.2.10.0030.00619.26
8.2.00.0070.00019.20
8.1.280.0110.00425.92
8.1.270.0040.00423.99
8.1.260.0040.00428.09
8.1.250.0030.00628.09
8.1.240.0050.00524.02
8.1.230.0060.00620.99
8.1.220.0000.00817.74
8.1.210.0060.00618.77
8.1.200.0040.00817.13
8.1.190.0070.00417.35
8.1.180.0050.00318.10
8.1.170.0040.00417.62
8.1.160.0070.00418.96
8.1.150.0000.00718.96
8.1.140.0050.00318.91
8.1.130.0000.00820.14
8.1.120.0080.00317.63
8.1.110.0000.00817.52
8.1.100.0000.00917.61
8.1.90.0020.00517.58
8.1.80.0000.00717.53
8.1.70.0050.00217.62
8.1.60.0040.00417.80
8.1.50.0060.00317.58
8.1.40.0060.00317.68
8.1.30.0030.00517.70
8.1.20.0000.00817.71
8.1.10.0040.00417.76
8.1.00.0000.00817.63
8.0.300.0000.00719.86
8.0.290.0050.00216.75
8.0.280.0040.00418.48
8.0.270.0040.00418.09
8.0.260.0030.00320.26
8.0.250.0000.00717.09
8.0.240.0060.00317.07
8.0.230.0000.00716.98
8.0.220.0030.00316.95
8.0.210.0000.00717.04
8.0.200.0000.00717.13
8.0.190.0050.00217.14
8.0.180.0040.00417.02
8.0.170.0040.00416.95
8.0.160.0040.00417.04
8.0.150.0000.00717.04
8.0.140.0030.00417.01
8.0.130.0050.00013.52
8.0.120.0040.00417.05
8.0.110.0030.00516.99
8.0.100.0000.00816.99
8.0.90.0070.00017.08
8.0.80.0110.01016.98
8.0.70.0000.00716.98
8.0.60.0000.00716.99
8.0.50.0040.00416.94
8.0.30.0120.00417.28
8.0.20.0000.01617.53
8.0.10.0080.00817.10
8.0.00.0030.01317.15
7.4.330.0020.00215.55
7.4.320.0070.00016.73
7.4.300.0070.00016.83
7.4.290.0080.00016.71
7.4.280.0130.00016.57
7.4.270.0030.00316.71
7.4.260.0000.00513.51
7.4.250.0040.00416.65
7.4.240.0040.00416.79
7.4.230.0000.00816.63
7.4.220.0050.00216.90
7.4.210.0080.00816.80
7.4.200.0030.00616.89
7.4.160.0070.01016.72
7.4.150.0080.00816.76
7.4.140.0030.01316.84
7.4.130.0060.01516.82
7.4.120.0090.00616.70
7.4.110.0060.00916.39
7.4.100.0060.00916.88
7.4.90.0040.01516.55
7.4.80.0080.00816.76
7.4.70.0030.01216.67
7.4.60.0080.00816.62
7.4.50.0050.01016.66
7.4.40.0050.01016.71
7.4.30.0110.00416.63
7.4.20.0030.01316.71
7.4.10.0070.01016.82
7.4.00.0050.01116.85
7.3.330.0040.00416.30
7.3.320.0000.00613.31
7.3.310.0070.00016.30
7.3.300.0040.00416.32
7.3.290.0010.01316.37
7.3.270.0070.01016.81
7.3.260.0080.00816.84
7.3.250.0070.01016.80
7.3.240.0080.00816.73
7.3.230.0060.01116.66
7.3.220.0100.01016.46
7.3.210.0090.00616.52
7.3.200.0060.01016.61
7.3.190.0050.01016.75
7.3.180.0120.00316.50
7.3.170.0140.00316.51
7.3.160.0080.00816.63
7.3.150.0120.00316.45
7.3.140.0100.00616.72
7.3.130.0170.00016.87
7.3.120.0100.00616.51
7.3.110.0030.01316.88
7.3.100.0050.01016.71
7.3.90.0130.00316.80
7.3.80.0040.01116.45
7.3.70.0060.01016.65
7.3.60.0090.00716.60
7.3.50.0080.00816.66
7.3.40.0100.00616.54
7.3.30.0080.00816.50
7.3.20.0110.00516.61
7.3.10.0060.01016.56
7.3.00.0100.01316.53

preferences:
38.84 ms | 400 KiB | 5 Q