3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Task 2: Parse the string * * Parse the $input string and build object tree that represents this structure: * https://drive.google.com/file/d/0BwhWcFzxN6_mZ2hkQlhZTnRrMDA/view?usp=sharing * Use Node class to build the tree and dump it to output * * Realize Node::dump() function and use it to output the tree in format: * A * B * C * C * C * B * C * C * A * B * B * C */ $input = 'A(B(CCC)B(CC))A(BB(C))'; class Node { public $letter; private $items = []; public function __construct($letter) { $this->letter = $letter; } public function addItem($item) { $this->items[] = $item; } public function dump($level = 0) { // write your code here... } } function createTree(string $input) { $jsonInput = $input; $jsonInput = str_replace(['(', ')'], ['[', ']'], $jsonInput); $jsonInput = preg_replace('~(\w)\[~', '"${1}":\[', $jsonInput); echo $jsonInput; } createTree($input);

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.70.0150.00618.43
8.3.60.0060.00916.50
8.3.50.0100.00817.56
8.3.40.0150.00619.02
8.3.30.0060.00918.83
8.3.20.0060.00920.35
8.3.10.0070.00021.85
8.3.00.0060.00319.66
8.2.180.0150.00018.63
8.2.170.0120.00322.96
8.2.160.0030.01019.04
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0040.00421.17
8.2.120.0000.00726.35
8.2.110.0070.00322.19
8.2.100.0080.00418.03
8.2.90.0000.00819.22
8.2.80.0040.00417.97
8.2.70.0050.00317.63
8.2.60.0000.00817.55
8.2.50.0030.00618.10
8.2.40.0000.00720.42
8.2.30.0050.00219.34
8.2.20.0000.00718.13
8.2.10.0040.00418.05
8.2.00.0000.00718.19
8.1.280.0090.01325.92
8.1.270.0080.00022.20
8.1.260.0080.00026.35
8.1.250.0070.00328.09
8.1.240.0040.00422.80
8.1.230.0060.00617.82
8.1.220.0000.00817.79
8.1.210.0040.00418.77
8.1.200.0040.00417.47
8.1.190.0000.00817.23
8.1.180.0040.00418.10
8.1.170.0050.00318.72
8.1.160.0000.00718.95
8.1.150.0030.00518.76
8.1.140.0070.00019.59
8.1.130.0000.00818.85
8.1.120.0070.00017.48
8.1.110.0040.00417.54
8.1.100.0080.00017.55
8.1.90.0000.00817.41
8.1.80.0030.00517.43
8.1.70.0000.00717.40
8.1.60.0080.00017.64
8.1.50.0000.00917.66
8.1.40.0040.00417.68
8.1.30.0000.00717.82
8.1.20.0020.00517.80
8.1.10.0080.00017.68
8.1.00.0000.00717.66
8.0.300.0040.00418.77
8.0.290.0080.00016.75
8.0.280.0030.00318.53
8.0.270.0030.00317.32
8.0.260.0070.00018.95
8.0.250.0000.00717.00
8.0.240.0000.00717.11
8.0.230.0070.00416.91
8.0.220.0000.00716.95
8.0.210.0000.00717.00
8.0.200.0000.00716.93
8.0.190.0060.00317.07
8.0.180.0030.00516.88
8.0.170.0000.00716.91
8.0.160.0030.00516.89
8.0.150.0030.00516.92
8.0.140.0090.00016.93
8.0.130.0070.00013.36
8.0.120.0000.00716.95
8.0.110.0030.00616.95
8.0.100.0040.00316.77
8.0.90.0040.00416.92
8.0.80.0160.00616.95
8.0.70.0000.00716.93
8.0.60.0040.00416.86
8.0.50.0000.00916.86
8.0.30.0080.00917.30
8.0.20.0130.00717.44
8.0.10.0080.00017.06
8.0.00.0070.01817.15
7.4.330.0060.00015.55
7.4.320.0030.00316.72
7.4.300.0070.00016.68
7.4.290.0030.00616.73
7.4.280.0070.00016.72
7.4.270.0040.00416.76
7.4.260.0070.00316.68
7.4.250.0040.00416.82
7.4.240.0000.00716.66
7.4.230.0000.00716.61
7.4.220.0100.00716.89
7.4.210.0080.00716.80
7.4.200.0020.00516.82
7.4.160.0080.01016.78
7.4.150.0150.00317.40
7.4.140.0100.00717.86
7.4.130.0090.00916.73
7.4.120.0050.01416.71
7.4.110.0120.00616.70
7.4.100.0100.00716.89
7.4.90.0080.00916.90
7.4.80.0060.01219.39
7.4.70.0060.01016.58
7.4.60.0000.01616.84
7.4.50.0070.00716.77
7.4.40.0100.00616.75
7.4.30.0030.01316.88
7.4.00.0090.00915.04
7.3.330.0070.00013.36
7.3.320.0000.00513.58
7.3.310.0000.00716.55
7.3.300.0070.00016.53
7.3.290.0030.00316.51
7.3.280.0070.00816.49
7.3.270.0090.00917.40
7.3.260.0100.00916.52
7.3.250.0100.01316.66
7.3.240.0060.01116.66
7.3.230.0120.00716.80
7.3.210.0090.00916.45
7.3.200.0090.00916.48
7.3.190.0090.01016.80
7.3.180.0120.01016.33
7.3.170.0120.00316.64
7.3.160.0000.01616.86
7.3.10.0040.00416.63
7.3.00.0030.01016.58
7.2.330.0100.00716.98
7.2.320.0120.01116.74
7.2.310.0080.00816.86
7.2.300.0160.00016.75
7.2.290.0140.00316.68
7.2.130.0080.00417.13
7.2.120.0100.00317.15
7.2.110.0070.00317.16
7.2.100.0030.00617.00
7.2.90.0040.00816.95
7.2.80.0030.00716.88
7.2.70.0110.00017.23
7.2.60.0030.00716.98
7.2.50.0070.00417.07
7.2.40.0060.00616.83
7.2.30.0140.00317.13
7.2.20.0030.01017.21
7.2.10.0090.00017.17
7.2.00.0100.00317.06
7.1.250.0090.00015.89
7.1.200.0180.00615.92
7.1.70.1720.01315.74
7.1.60.1200.01433.60
7.1.50.1460.01633.18
7.1.40.0270.01034.85
7.1.30.0310.00734.78
7.1.20.0220.01934.82
7.1.10.0070.01316.75
7.1.00.0010.02417.11
7.0.200.1500.01115.21
7.0.190.1850.00914.86
7.0.180.0450.00716.38
7.0.170.0170.00316.40
7.0.160.0060.01016.35
7.0.150.0110.01016.38
7.0.140.0100.01016.77
7.0.130.0140.00616.79
7.0.120.0150.00616.65
7.0.110.0070.01216.75
7.0.100.0160.00716.65
7.0.90.0120.00816.50
7.0.80.0090.01216.59
7.0.70.0090.01216.71
7.0.60.0070.00716.27
7.0.50.0160.00616.62
7.0.40.0080.01516.81
7.0.30.0060.01416.62
7.0.20.0090.01016.70
7.0.10.0090.01516.59
7.0.00.0120.00716.72

preferences:
68.69 ms | 401 KiB | 5 Q