3v4l.org

run code in 300+ PHP versions simultaneously
<?php function regexp($string, $pattern) { return preg_match('/'.$pattern.'/', $string); } function getLeftDelimiter($string, $pattern) { $result = ''; while(1) { $current = $string; $position = strlen($string); while($position && regexp($current, $pattern)) { $position--; $current = substr($current, 0, -1); } $current = substr($string, 0, $position+1); if(regexp($current, '^('.$pattern.')$')) { $result .= $current; $string = substr($string, $position+1); } else { return $result; } } } function getRightDelimiter($string, $pattern) { $result = ''; while(1) { $current = $string; $position = 0; while($position<strlen($string) && regexp($current, $pattern)) { $position++; $current = substr($current, 1); } $current = substr($string, $position-1); if(regexp($current, '^('.$pattern.')$')) { $result = $current.$result; $string = substr($string, 0, $position-1); } else { return $result; } } } function getLeftChunk($string, $pattern) { $result = ''; $current = ''; $position= 0; while($position<strlen($string) && !regexp($current, $pattern)) { $position++; $current = substr($string, 0, $position); } $delimiter = getRightDelimiter($current, $pattern); return substr($current, 0, strlen($current)-strlen($delimiter)); } function regexpSplit($string, $pattern) { $result = []; $i = 0; while($string && ++$i<10) { $delimiter = getLeftDelimiter($string, $pattern); if($delimiter==$string) { break; } $string = substr($string, strlen($delimiter)); $chunk = getLeftChunk($string, $pattern); $string = substr($string, strlen($chunk)); $result[] = $chunk; } return $result; } $string = 'tbarbarfob12baz 56bar'; $pattern = 'bar|baz'; var_dump(regexpSplit($string, $pattern));

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.0100.00317.13
8.3.50.0100.01022.03
8.3.40.0090.00919.09
8.3.30.0110.00419.22
8.3.20.0040.00420.34
8.3.10.0040.00423.53
8.3.00.0000.00819.63
8.2.180.0120.00918.42
8.2.170.0180.00022.96
8.2.160.0140.00020.34
8.2.150.0100.00024.18
8.2.140.0050.00324.66
8.2.130.0140.00426.16
8.2.120.0070.00022.24
8.2.110.0050.00522.25
8.2.100.0000.01218.28
8.2.90.0000.00819.48
8.2.80.0040.00417.97
8.2.70.0000.00918.13
8.2.60.0000.00918.03
8.2.50.0030.00518.07
8.2.40.0030.00520.07
8.2.30.0000.00718.24
8.2.20.0060.00317.93
8.2.10.0040.00420.00
8.2.00.0110.00018.01
8.1.280.0220.00725.92
8.1.270.0030.00623.83
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0090.00023.98
8.1.230.0110.00019.18
8.1.220.0040.00417.91
8.1.210.0090.00018.77
8.1.200.0000.00917.50
8.1.190.0030.00517.53
8.1.180.0030.00918.10
8.1.170.0060.00618.77
8.1.160.0070.00022.05
8.1.150.0040.00418.84
8.1.140.0030.00617.72
8.1.130.0030.00317.96
8.1.120.0050.00217.71
8.1.110.0030.00717.62
8.1.100.0090.00017.67
8.1.90.0000.00817.66
8.1.80.0040.00417.55
8.1.70.0080.00017.64
8.1.60.0030.00617.80
8.1.50.0000.00817.66
8.1.40.0060.00317.78
8.1.30.0030.00617.81
8.1.20.0040.00417.76
8.1.10.0000.00817.61
8.1.00.0040.00417.64
8.0.300.0070.00018.77
8.0.290.0040.00417.18
8.0.280.0070.00018.52
8.0.270.0040.00417.24
8.0.260.0030.00317.33
8.0.250.0030.00317.21
8.0.240.0060.00317.23
8.0.230.0050.00317.22
8.0.220.0030.00317.12
8.0.210.0060.00317.06
8.0.200.0000.00717.13
8.0.190.0050.00317.20
8.0.180.0040.00417.16
8.0.170.0060.00317.07
8.0.160.0050.00217.23
8.0.150.0040.00417.12
8.0.140.0050.00217.01
8.0.130.0000.00513.66
8.0.120.0040.00417.16
8.0.110.0000.00717.05
8.0.100.0000.00716.99
8.0.90.0000.00917.16
8.0.80.0060.00917.14
8.0.70.0080.00017.08
8.0.60.0000.00817.04
8.0.50.0050.00317.17
8.0.30.0120.01017.50
8.0.20.0090.01217.40
8.0.10.0050.00317.14
8.0.00.0160.00216.85
7.4.330.0000.00515.05
7.4.320.0040.00416.92
7.4.300.0000.00616.78
7.4.290.0000.00716.75
7.4.280.0070.00016.75
7.4.270.0000.00716.79
7.4.260.0030.00316.77
7.4.250.0030.00516.88
7.4.240.0030.00516.79
7.4.230.0040.00416.94
7.4.220.0030.01216.88
7.4.210.0080.00716.86
7.4.200.0070.00016.52
7.4.190.0000.00716.83
7.4.160.0060.01116.59
7.4.150.0130.00417.40
7.4.140.0140.00417.86
7.4.130.0070.01016.78
7.4.120.0080.01016.72
7.4.110.0180.00316.64
7.4.100.0100.00716.80
7.4.90.0090.01216.71
7.4.80.0170.00319.39
7.4.70.0070.01016.98
7.4.60.0080.01516.69
7.4.50.0030.00616.70
7.4.40.0100.00722.77
7.4.30.0060.01016.67
7.4.00.0060.00915.20
7.3.330.0000.00613.41
7.3.320.0000.00813.65
7.3.310.0040.00416.62
7.3.300.0020.00516.63
7.3.290.0040.01116.61
7.3.280.0120.00416.60
7.3.270.0150.00417.40
7.3.260.0210.00316.74
7.3.250.0080.00916.74
7.3.240.0070.01016.63
7.3.230.0000.01716.57
7.3.210.0060.01216.58
7.3.200.0090.01519.39
7.3.190.0130.00316.94
7.3.180.0090.00616.81
7.3.170.0130.00916.69
7.3.160.0040.01216.78
7.3.120.0110.00715.16
7.3.110.0040.00815.17
7.3.100.0060.00915.11
7.3.90.0000.01514.84
7.3.80.0100.00614.96
7.3.70.0030.01315.07
7.3.60.0000.01114.97
7.3.50.0040.00815.16
7.3.40.0090.00614.95
7.3.30.0070.00715.04
7.3.20.0090.00916.62
7.3.10.0090.00716.81
7.3.00.0040.01116.82
7.2.330.0100.00716.69
7.2.320.0070.01116.90
7.2.310.0090.01116.93
7.2.300.0130.00316.94
7.2.290.0060.01217.02
7.2.250.0070.01114.89
7.2.240.0070.01315.25
7.2.230.0100.00614.96
7.2.220.0040.01115.40
7.2.210.0070.01015.08
7.2.200.0060.01015.26
7.2.190.0040.00815.38
7.2.180.0060.00915.32
7.2.170.0030.01215.05
7.2.60.0040.01117.14
7.2.00.0070.00719.75
7.1.330.0030.01016.09
7.1.320.0040.00715.86
7.1.310.0030.00915.87
7.1.300.0100.00315.95
7.1.290.0030.01016.22
7.1.280.0030.01215.92
7.1.270.0000.01315.85
7.1.260.0090.00316.05
7.1.200.0070.00716.05
7.1.100.0250.00418.12
7.1.70.0100.00017.38
7.1.60.0040.00719.46
7.1.50.0090.01317.12
7.1.00.0030.07722.42
7.0.200.1090.01015.04
7.0.140.0000.07721.97
7.0.60.0130.07720.02
7.0.50.0030.04017.93
7.0.40.0070.06320.23
7.0.30.0230.08320.21
7.0.20.0170.04020.25
7.0.10.0470.06720.25
7.0.00.0130.08320.21
5.6.280.0030.07020.93
5.6.210.0100.04720.70
5.6.200.0130.05718.13
5.6.190.0100.05720.77
5.6.180.3870.03720.36
5.6.170.0270.08320.55
5.6.160.0070.06020.71
5.6.150.0100.03718.18
5.6.140.0070.07718.14
5.6.130.0030.08718.25
5.6.120.0000.04721.03
5.6.110.0170.07021.13
5.6.100.0100.06320.99
5.6.90.0030.04721.02
5.6.80.0030.06720.45
5.6.70.0070.07020.54
5.5.350.0200.06720.39
5.5.340.0070.05317.93
5.5.330.0130.07320.27
5.5.320.0070.06320.13
5.5.310.0300.07320.43
5.5.300.0070.08017.95
5.5.290.0100.07018.00
5.5.280.0030.06020.88
5.5.270.0100.07020.69
5.5.260.0100.04320.85
5.5.250.0100.04020.59
5.5.240.0130.03320.27
5.4.450.0600.05719.52
5.4.440.0130.04319.52
5.4.430.0170.07719.45
5.4.420.0230.04719.41
5.4.410.0200.03719.18
5.4.400.0230.07019.17
5.4.390.3200.03718.99
5.4.380.0300.05719.09
5.4.370.0330.07319.08
5.4.360.0300.05019.24
5.4.350.0200.04318.84
5.4.340.0100.04318.84
5.4.320.0430.06019.00
5.4.310.0330.03719.31
5.4.300.0230.04318.87
5.4.290.0040.05112.50
5.4.280.0060.03712.40
5.4.270.0050.04112.41
5.4.260.0030.04212.41
5.4.250.0070.03812.40
5.4.240.0080.03412.40
5.4.230.0060.03912.39
5.4.220.0040.03912.39
5.4.210.0060.03612.40
5.4.200.0030.04212.39
5.4.190.0090.03612.39
5.4.180.0050.03712.39
5.4.170.0060.04112.40
5.4.160.0050.03812.39
5.4.150.0090.03412.39
5.4.140.0070.04512.07
5.4.130.0090.03712.06
5.4.120.0060.04212.02
5.4.110.0040.04112.02
5.4.100.0070.04812.01
5.4.90.0090.05312.01
5.4.80.0070.04512.02
5.4.70.0080.04512.00
5.4.60.0080.03712.01
5.4.50.0080.04112.01
5.4.40.0070.03812.00
5.4.30.0090.04412.00
5.4.20.0070.03611.99
5.4.10.0060.03711.99
5.4.00.0060.05311.48
5.3.290.3970.04015.82
5.3.280.0090.05512.71
5.3.270.0130.06812.72
5.3.260.0050.06912.72
5.3.250.0100.03612.72
5.3.240.0100.03712.72
5.3.230.0050.04912.71
5.3.220.0100.03312.68
5.3.210.0050.05112.68
5.3.200.0070.03612.68
5.3.190.0090.03912.68
5.3.180.0110.05312.67
5.3.170.0070.03612.66
5.3.160.0040.03812.68
5.3.150.0060.03812.67
5.3.140.0070.03612.66
5.3.130.0030.04212.66
5.3.120.0060.03812.66
5.3.110.0060.03912.65
5.3.100.0050.03812.14
5.3.90.0030.03912.13
5.3.80.0080.03812.12
5.3.70.0080.05012.12
5.3.60.0060.03912.10
5.3.50.0060.03512.04
5.3.40.0080.03412.05
5.3.30.0030.03712.00
5.3.20.0060.04011.79
5.3.10.0080.03511.75
5.3.00.0040.04111.75
5.2.170.0050.0369.25
5.2.160.0060.0419.25
5.2.150.0040.0469.25
5.2.140.0070.0479.24
5.2.130.0090.0379.20
5.2.120.0080.0359.21
5.2.110.0050.0349.21
5.2.100.0110.0569.20
5.2.90.0140.0699.20
5.2.80.0200.0759.20
5.2.70.0050.0379.20
5.2.60.0090.0379.16
5.2.50.0060.0439.13
5.2.40.0030.0449.11
5.2.30.0050.0329.07
5.2.20.0120.0449.06
5.2.10.0060.0388.97
5.2.00.0050.0358.83
5.1.60.0070.0368.12
5.1.50.0100.0438.11
5.1.40.0070.0338.10
5.1.30.0070.0288.45
5.1.20.0070.0278.47
5.1.10.0080.0248.19
5.1.00.0060.0258.19
5.0.50.0030.0296.68
5.0.40.0040.0216.54
5.0.30.0050.0426.36
5.0.20.0040.0246.32
5.0.10.0050.0206.30
5.0.00.0100.0456.30
4.4.90.0040.0164.78
4.4.80.0020.0244.75
4.4.70.0050.0264.75
4.4.60.0020.0234.75
4.4.50.0010.0254.77
4.4.40.0040.0354.71
4.4.30.0030.0224.76
4.4.20.0060.0244.84
4.4.10.0030.0154.85
4.4.00.0010.0264.76
4.3.110.0020.0164.67
4.3.100.0010.0174.67
4.3.90.0030.0154.63
4.3.80.0030.0274.58
4.3.70.0070.0174.63
4.3.60.0010.0184.63
4.3.50.0030.0164.63
4.3.40.0050.0254.54
4.3.30.0040.0223.33
4.3.20.0030.0183.31
4.3.10.0000.0283.28
4.3.00.0130.03013.91

preferences:
68.87 ms | 400 KiB | 5 Q