3v4l.org

run code in 300+ PHP versions simultaneously
<?php function renderBlock(array $m) { $callable = "build$m[1]"; return function_exists($callable) ? $callable($m[2] ?? '') : $m[0]; } function buildPiechart(string $payloadString) { $values = [ 'angle' => 0, 'colorset' => 'red', 'stroke' => 1, 'value' => 1 ]; $rules = [ 'angle' => '/\d+/', 'colorset' => '/reds|yellows|blues/i', 'stroke' => '/\d+/', 'value' => '/\d+/', ]; $attributes = preg_split( '/\h+/u', $payloadString, 0, PREG_SPLIT_NO_EMPTY ); foreach ($attributes as $pair) { [$key, $value] = explode(':', $pair, 2); if ( key_exists($key, $values) && preg_match($rules[$key], $value, $m) ) { $values[$key] = $m[0]; } } return sprintf( '<pie a="%s" c="%s" s="%s" v="%s">', ...array_values($values) ); } $text = 'here is a block to be replaced [block:piechart value:25 angle:0] [block] and [block:notcoded attr:val] another one [block:piechart colorset:reds value:20]'; echo preg_replace_callback( '/\[block:([a-z]+)\h*([^\]\r\n]*)\]/u', 'renderBlock', $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.4.130.0110.01023.92
8.4.120.0120.00818.98
8.4.110.0140.00618.89
8.4.100.0120.00918.10
8.4.90.0030.00722.63
8.4.80.0070.00219.12
8.4.70.0120.00919.96
8.4.60.0040.00420.77
8.4.50.0110.01119.77
8.4.40.0030.00918.16
8.4.30.0080.00318.75
8.4.20.0060.00618.01
8.4.10.0000.00922.16
8.3.260.0110.00816.96
8.3.250.0100.01017.11
8.3.240.0090.01016.81
8.3.230.0090.01117.19
8.3.220.0070.00918.79
8.3.210.0100.00518.59
8.3.200.0110.00516.88
8.3.190.0040.00417.06
8.3.180.0110.00818.85
8.3.170.0070.01316.91
8.3.160.0110.00716.86
8.3.150.0060.01217.31
8.3.140.0050.00318.90
8.3.130.0130.00318.80
8.3.120.0130.00718.99
8.3.110.0190.00020.94
8.3.100.0040.00424.06
8.3.90.0040.00426.77
8.3.80.0040.00817.00
8.3.70.0030.01318.43
8.3.60.0130.00318.68
8.3.50.0100.01018.42
8.3.40.0090.00919.05
8.3.30.0070.01319.01
8.3.20.0030.00624.18
8.3.10.0000.00824.66
8.3.00.0130.00626.16
8.2.290.0100.01017.17
8.2.280.0050.00418.62
8.2.270.0040.01516.98
8.2.260.0110.00718.66
8.2.250.0080.00017.00
8.2.240.0110.00417.26
8.2.230.0160.00322.58
8.2.220.0090.00037.54
8.2.210.0070.00426.77
8.2.200.0030.00617.00
8.2.190.0130.00716.75
8.2.180.0060.01025.92
8.2.170.0090.01219.04
8.2.160.0110.01122.96
8.2.150.0080.00025.66
8.2.140.0070.00724.66
8.2.130.0090.00026.16
8.2.120.0090.00019.05
8.2.110.0060.00320.35
8.2.100.0060.00619.88
8.2.90.0000.00817.88
8.2.80.0030.00618.91
8.2.70.0040.00417.88
8.2.60.0060.00318.05
8.2.50.0040.00418.07
8.2.40.0090.00018.34
8.2.30.0040.00418.16
8.2.20.0050.00320.54
8.2.10.0040.00418.24
8.2.00.0030.00619.43
8.1.330.0120.00816.29
8.1.320.0080.01116.34
8.1.310.0110.00416.82
8.1.300.0060.00318.41
8.1.290.0040.00730.84
8.1.280.0110.00425.92
8.1.270.0140.00023.99
8.1.260.0000.00826.35
8.1.250.0100.00028.09
8.1.240.0100.00019.07
8.1.230.0060.00617.95
8.1.220.0030.00618.03
8.1.210.0000.00818.77
8.1.200.0060.00317.60
8.1.190.0040.00817.60
8.1.180.0040.00418.10
8.1.170.0050.00318.74
8.1.160.0040.00418.93
8.1.150.0040.00418.83
8.1.140.0030.00517.71
8.1.130.0080.00018.93
8.1.120.0040.00417.65
8.1.110.0040.00417.61
8.1.100.0080.00017.65
8.1.90.0000.00817.59
8.1.80.0050.00517.60
8.1.70.0120.00617.58
8.1.60.0180.00417.75
8.1.50.0140.00417.76
8.1.40.0160.00317.70
8.1.30.0100.00917.75
8.1.20.0090.01417.60
8.1.10.0130.00717.78
8.1.00.0180.00317.63
8.0.300.0060.00318.77
8.0.290.0040.00417.00
8.0.280.0030.00318.55
8.0.270.0080.00018.18
8.0.260.0030.00318.49
8.0.250.0000.00717.23
8.0.240.0030.00317.13
8.0.230.0050.00617.17
8.0.220.0000.00717.23
8.0.210.0090.00917.10
8.0.200.0060.01117.20
8.0.190.0160.00017.19
8.0.180.0040.01317.04
8.0.170.0110.00617.20
8.0.160.0110.00617.21
8.0.150.0040.01317.06
8.0.140.0140.00417.13
8.0.130.0080.00417.14
8.0.120.0100.00717.09
8.0.110.0080.00417.04
8.0.100.0170.00017.12
8.0.90.0090.00417.11
8.0.80.0130.00417.21
8.0.70.0070.00717.22
8.0.60.0040.00717.14
8.0.50.0090.00717.23
8.0.30.0090.00717.15
8.0.20.0150.00117.29
8.0.10.0150.00417.24
7.4.330.0040.00415.55
7.4.320.0000.00616.95
7.4.300.0040.01316.84
7.4.290.0120.00616.78
7.4.280.0100.00716.73
7.4.270.0030.00516.89
7.4.260.0040.00416.91
7.4.250.0060.00616.75
7.4.240.0110.00016.73
7.4.230.0080.00416.82
7.4.220.0090.00516.90
7.4.210.0000.01516.89
7.4.200.0040.01316.87
7.4.190.0120.00216.73
7.4.180.0120.00416.80
7.4.160.0100.00316.80
7.4.150.0100.00516.82
7.4.140.0160.00016.82
7.4.130.0080.00916.77
7.4.120.0040.00416.66
7.4.110.0050.00316.76
7.4.100.0080.00016.90
7.4.90.0040.00816.82
7.4.80.0090.00316.86
7.4.70.0070.00416.84
7.4.60.0040.00716.66
7.4.50.0080.00416.53
7.4.40.0070.00516.70
7.4.30.0070.00516.76
7.4.20.0070.00316.59
7.4.10.0050.00516.70
7.4.00.0000.00916.67

preferences:
28.76 ms | 403 KiB | 5 Q