3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = <<<TEXT == My Subheading == === My sub Subheading === ==== another heading ==== TEXT; class ContentParser { private $patterns = []; private $replacements = []; public function __construct() { $this->patterns = [ // Headings "/^==== (.+?) ====\h*$/m", "/^=== (.+?) ===\h*$/m", "/^== (.+?) ==\h*$/m", ]; $this->replacements = [ // Headings "<h3>$1</h3>", "<h2>$1</h2>", "<h1>$1</h1>", ]; } public function parse($input) { if (!empty($input)) { $output = preg_replace($this->patterns, $this->replacements, $input); } else { $output = false; // I don't recommend returning a boolean when otherwise returning strings } return $output; } } $object = new ContentParser(); var_export($object->parse($text));

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.5.30.0080.01117.49
8.5.20.0110.00719.39
8.5.10.0070.01216.91
8.5.00.0120.01020.30
8.4.180.0080.00219.94
8.4.170.0130.00923.75
8.4.160.0120.00923.93
8.4.150.0060.00416.87
8.4.140.0110.01017.54
8.4.130.0140.00717.88
8.4.120.0040.00520.50
8.4.110.0110.00820.58
8.4.100.0130.00817.70
8.4.90.0140.00720.36
8.4.80.0100.00922.23
8.4.70.0050.00417.93
8.4.60.0100.01018.77
8.4.50.0120.00817.95
8.4.40.0130.00617.79
8.4.30.0060.01322.05
8.4.20.0130.00619.97
8.4.10.0100.01019.85
8.3.300.0110.01020.95
8.3.290.0120.00820.79
8.3.280.0100.01118.57
8.3.270.0090.01016.58
8.3.260.0100.00916.92
8.3.250.0150.00418.84
8.3.240.0110.00816.89
8.3.230.0090.00816.73
8.3.220.0110.00819.08
8.3.210.0100.00616.78
8.3.200.0040.00516.67
8.3.190.0100.00716.94
8.3.180.0160.00317.02
8.3.170.0090.00916.75
8.3.160.0070.01116.95
8.3.150.0050.01417.38
8.3.140.0130.00616.52
8.3.130.0030.00618.66
8.3.120.0060.00320.71
8.3.110.0070.00320.94
8.3.100.0060.00324.06
8.3.90.0050.00326.77
8.3.80.0050.00516.88
8.3.70.0090.01218.68
8.3.60.0120.00316.50
8.3.50.0070.01224.66
8.3.40.0070.00721.89
8.3.30.0070.00718.92
8.3.20.0070.00024.18
8.3.10.0000.00724.66
8.3.00.0050.00326.16
8.2.300.0070.01318.86
8.2.290.0110.00719.24
8.2.280.0100.01018.63
8.2.270.0090.00617.34
8.2.260.0120.00616.82
8.2.250.0080.00016.78
8.2.240.0060.00317.20
8.2.230.0060.00322.58
8.2.220.0090.00937.54
8.2.210.0060.00326.77
8.2.200.0100.00017.00
8.2.190.0070.00716.75
8.2.180.0070.01125.92
8.2.170.0070.00719.23
8.2.160.0110.00322.96
8.2.150.0080.00025.66
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0000.00819.90
8.2.110.0030.00719.39
8.2.100.0110.00018.03
8.2.90.0080.00019.82
8.2.80.0040.00417.97
8.2.70.0040.00417.89
8.2.60.0030.00618.09
8.2.50.0040.00418.10
8.2.40.0060.00321.33
8.2.30.0020.00519.24
8.2.20.0050.00318.10
8.2.10.0000.00719.30
8.2.00.0040.00419.28
8.1.340.0090.01219.78
8.1.330.0160.00416.64
8.1.320.0100.00916.61
8.1.310.0060.00616.65
8.1.300.0120.00316.38
8.1.290.0060.00618.88
8.1.280.0040.01125.92
8.1.270.0080.00023.99
8.1.260.0060.00326.35
8.1.250.0000.00828.09
8.1.240.0060.00322.59
8.1.230.0040.00822.80
8.1.220.0050.00317.79
8.1.210.0040.00418.77
8.1.200.0030.00617.47
8.1.190.0000.00817.35
8.1.180.0040.00418.10
8.1.170.0030.00518.76
8.1.160.0040.00419.04
8.1.150.0030.00718.93
8.1.140.0030.00518.84
8.1.130.0000.00720.25
8.1.120.0030.00517.58
8.1.110.0000.00817.63
8.1.100.0030.00517.53
8.1.90.0000.00717.59
8.1.80.0030.00617.52
8.1.70.0000.00817.67
8.1.60.0070.00317.75
8.1.50.0060.00617.70
8.1.40.0040.00417.69
8.1.30.0090.00017.79
8.1.20.0040.00417.85
8.1.10.0080.00017.73
8.1.00.0030.00517.49
8.0.300.0000.00920.15
8.0.290.0040.00417.00
8.0.280.0000.00818.42
8.0.270.0040.00418.23
8.0.260.0000.00618.64
8.0.250.0030.00317.19
8.0.240.0040.00417.05
8.0.230.0040.00417.14
8.0.220.0000.00817.00
8.0.210.0030.00317.10
8.0.200.0040.00417.14
8.0.190.0000.00917.18
8.0.180.0000.00717.13
8.0.170.0060.00517.15
8.0.160.0040.00417.19
8.0.150.0000.00716.95
8.0.140.0030.00617.07
8.0.130.0060.00013.50
8.0.120.0000.00817.07
8.0.110.0070.00017.00
8.0.100.0040.00416.98
8.0.90.0040.00417.07
8.0.80.0050.01517.04
8.0.70.0070.00016.92
8.0.60.0000.00717.12
8.0.50.0050.00316.99
8.0.30.0080.00817.41
8.0.20.0090.00917.09
8.0.10.0000.00717.04
8.0.00.0060.01317.00
7.4.330.0030.00315.55
7.4.320.0000.00616.87
7.4.300.0030.00316.82
7.4.290.0000.00816.68
7.4.280.0070.00016.80
7.4.270.0040.00416.80
7.4.260.0060.00013.50
7.4.250.0070.00016.79
7.4.240.0050.00216.86
7.4.230.0040.00416.82
7.4.220.0020.00616.76
7.4.210.0070.00816.73
7.4.200.0000.00916.89
7.4.130.0140.00316.68
7.4.120.0070.01016.66
7.4.110.0070.01116.75
7.4.100.0110.00716.72
7.4.90.0070.01016.71
7.4.80.0070.01016.63
7.4.70.0130.00316.56
7.4.60.0130.00316.57
7.4.50.0110.01516.68
7.4.40.0140.00416.58
7.4.30.0060.01116.64
7.4.20.0130.00416.58
7.4.10.0100.00716.71
7.4.00.0140.00316.75
7.3.330.0000.00716.69
7.3.320.0000.00613.46
7.3.310.0000.00716.54
7.3.300.0000.00616.54
7.3.290.0050.01216.54
7.3.260.0060.01116.64
7.3.250.0110.00616.69
7.3.240.0090.00916.53
7.3.230.0110.00516.35
7.3.220.0060.01016.55
7.3.210.0090.00616.37
7.3.200.0130.00716.75
7.3.190.0100.01016.54
7.3.180.0070.01016.57
7.3.170.0210.00016.54
7.3.160.0120.00616.76
7.3.150.0090.00916.64
7.3.140.0130.00316.36
7.3.130.0190.00916.48
7.3.120.0060.01016.70
7.3.110.0070.01016.71
7.3.100.0130.00316.69
7.3.90.0170.00716.77
7.3.80.0130.01016.62
7.3.70.0100.01316.51
7.3.60.0080.00816.45
7.3.50.0080.00816.41
7.3.40.0070.01016.28
7.3.30.0070.01716.50
7.3.20.0090.00916.38
7.3.10.0100.00716.40
7.3.00.0090.00916.45

preferences:
63.79 ms | 1371 KiB | 5 Q