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.0140.00018.81
8.3.50.0140.00316.69
8.3.40.0180.00018.96
8.3.30.0120.00319.10
8.3.20.0000.00824.18
8.3.10.0000.00824.66
8.3.00.0000.00826.16
8.2.180.0120.00325.92
8.2.170.0000.01518.96
8.2.160.0040.01122.96
8.2.150.0070.00025.66
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0080.00026.35
8.2.110.0060.00321.10
8.2.100.0060.00617.91
8.2.90.0000.00818.03
8.2.80.0060.00319.05
8.2.70.0080.00017.88
8.2.60.0050.00318.03
8.2.50.0090.00018.05
8.2.40.0040.00418.22
8.2.30.0000.00718.23
8.2.20.0040.00418.26
8.2.10.0000.00719.21
8.2.00.0060.00319.23
8.1.280.0110.00425.92
8.1.270.0060.00324.02
8.1.260.0000.00828.09
8.1.250.0000.00728.09
8.1.240.0060.00322.03
8.1.230.0090.00320.91
8.1.220.0050.00517.79
8.1.210.0030.00518.77
8.1.200.0030.00617.47
8.1.190.0030.00617.35
8.1.180.0030.00518.10
8.1.170.0040.00418.74
8.1.160.0000.00718.80
8.1.150.0070.00018.92
8.1.140.0040.00418.84
8.1.130.0000.00720.14
8.1.120.0100.00017.63
8.1.110.0000.00817.61
8.1.100.0040.00417.62
8.1.90.0000.00717.49
8.1.80.0000.00817.66
8.1.70.0040.00417.64
8.1.60.0000.00817.72
8.1.50.0080.00017.63
8.1.40.0040.00417.65
8.1.30.0030.00617.76
8.1.20.0040.00417.82
8.1.10.0040.00417.73
8.1.00.0060.00317.56
8.0.300.0080.00020.10
8.0.290.0040.00416.88
8.0.280.0000.01018.39
8.0.270.0030.00318.10
8.0.260.0030.00320.30
8.0.250.0050.00317.01
8.0.240.0000.00816.98
8.0.230.0070.00017.09
8.0.220.0030.00317.05
8.0.210.0070.00017.10
8.0.200.0030.00316.99
8.0.190.0000.00717.15
8.0.180.0030.00516.96
8.0.170.0060.00317.07
8.0.160.0000.00716.94
8.0.150.0000.00716.94
8.0.140.0080.00016.89
8.0.130.0060.00013.43
8.0.120.0060.00317.01
8.0.110.0070.00017.09
8.0.100.0050.00216.91
8.0.90.0040.00417.09
8.0.80.0050.01617.10
8.0.70.0040.00417.00
8.0.60.0050.00217.05
8.0.50.0040.00417.02
8.0.30.0150.00217.14
8.0.20.0160.01017.16
8.0.10.0180.00717.23
8.0.00.0180.00717.24
7.4.330.0030.00315.55
7.4.320.0030.00316.78
7.4.300.0050.00216.72
7.4.290.0040.00416.74
7.4.280.0090.00016.66
7.4.270.0000.00816.74
7.4.260.0050.00013.52
7.4.250.0040.00416.79
7.4.240.0010.00716.66
7.4.230.0030.00316.91
7.4.220.0030.00416.66
7.4.210.0080.00816.74
7.4.200.0080.00016.90
7.4.160.0110.00616.74
7.4.150.0170.00516.59
7.4.140.0120.01316.76
7.4.130.0070.01416.75
7.4.120.0200.00516.69
7.4.110.0150.00716.65
7.4.100.0130.00916.76
7.4.90.0160.00616.62
7.4.80.0110.01216.53
7.4.70.0150.00816.69
7.4.60.0130.01116.50
7.4.50.0110.01016.75
7.4.40.0170.00516.69
7.4.30.0170.00516.72
7.4.20.0140.00816.68
7.4.10.0080.01316.72
7.4.00.0090.00816.82
7.3.330.0040.00416.37
7.3.320.0050.00013.31
7.3.310.0000.00716.42
7.3.300.0040.00416.34
7.3.290.0040.01116.45
7.3.270.0140.00916.67
7.3.260.0170.00616.60
7.3.250.0120.00916.62
7.3.240.0150.00616.45
7.3.230.0170.00616.68
7.3.220.0170.00916.46
7.3.210.0170.00516.64
7.3.200.0160.00816.69
7.3.190.0120.01016.73
7.3.180.0180.00716.64
7.3.170.0140.00916.67
7.3.160.0150.00616.68
7.3.150.0140.00716.53
7.3.140.0170.00916.56
7.3.130.0180.00616.55
7.3.120.0140.00816.46
7.3.110.0210.00316.67
7.3.100.0180.00616.58
7.3.90.0180.00616.42
7.3.80.0150.01116.63
7.3.70.0180.00616.54
7.3.60.0150.01016.57
7.3.50.0140.00916.59
7.3.40.0140.00716.65
7.3.30.0120.00916.51
7.3.20.0160.00616.54
7.3.10.0120.01216.50
7.3.00.0140.01016.59

preferences:
58.97 ms | 400 KiB | 5 Q