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.60.0000.01516.88
8.3.50.0100.01018.14
8.3.40.0040.01118.61
8.3.30.0090.00618.84
8.3.20.0070.00020.34
8.3.10.0050.00321.85
8.3.00.0060.00319.56
8.2.180.0110.00716.49
8.2.170.0070.01122.96
8.2.160.0070.00719.07
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0080.00021.25
8.2.120.0000.00826.35
8.2.110.0000.01022.21
8.2.100.0120.00017.84
8.2.90.0030.00519.14
8.2.80.0050.00317.97
8.2.70.0040.00417.75
8.2.60.0030.00617.80
8.2.50.0040.00418.10
8.2.40.0000.00922.32
8.2.30.0000.00719.36
8.2.20.0040.00418.08
8.2.10.0040.00418.02
8.2.00.0000.00718.02
8.1.280.0070.01125.92
8.1.270.0000.00821.93
8.1.260.0000.00826.35
8.1.250.0000.00828.09
8.1.240.0060.00320.93
8.1.230.0040.00719.16
8.1.220.0040.00417.74
8.1.210.0050.00318.77
8.1.200.0090.00017.35
8.1.190.0000.00817.36
8.1.180.0040.00418.10
8.1.170.0030.00618.69
8.1.160.0020.00518.99
8.1.150.0030.00518.81
8.1.140.0040.00419.45
8.1.130.0060.00318.80
8.1.120.0040.00417.51
8.1.110.0000.00717.53
8.1.100.0050.00217.48
8.1.90.0040.00417.44
8.1.80.0040.00417.53
8.1.70.0000.00717.52
8.1.60.0000.00817.61
8.1.50.0040.00417.55
8.1.40.0040.00417.50
8.1.30.0050.00317.88
8.1.20.0080.00017.72
8.1.10.0030.00517.64
8.1.00.0040.00417.61
8.0.300.0000.00718.77
8.0.290.0080.00016.75
8.0.280.0070.00018.57
8.0.270.0040.00417.35
8.0.260.0000.00718.82
8.0.250.0030.00316.98
8.0.240.0040.00416.98
8.0.230.0000.00817.03
8.0.220.0070.00016.87
8.0.210.0040.00416.98
8.0.200.0030.00316.90
8.0.190.0040.00417.00
8.0.180.0000.00716.97
8.0.170.0000.00816.86
8.0.160.0000.00716.89
8.0.150.0030.00516.98
8.0.140.0030.00616.95
8.0.130.0030.00313.34
8.0.120.0070.00016.97
8.0.110.0040.00416.97
8.0.100.0000.00716.84
8.0.90.0000.00916.89
8.0.80.0040.01216.93
8.0.70.0040.00417.03
8.0.60.0000.00716.87
8.0.50.0050.00316.89
8.0.30.0130.00417.07
8.0.20.0120.01017.48
8.0.10.0040.00417.09
8.0.00.0110.00717.07
7.4.330.0000.00615.55
7.4.320.0060.00016.66
7.4.300.0000.00716.75
7.4.290.0000.00816.72
7.4.280.0000.00716.79
7.4.270.0000.00716.78
7.4.260.0040.00716.67
7.4.250.0050.00316.68
7.4.240.0070.00016.79
7.4.230.0030.00316.61
7.4.220.0000.01816.73
7.4.210.0080.00816.78
7.4.200.0000.00716.63
7.4.160.0160.00416.73
7.4.150.0100.01017.40
7.4.140.0100.00717.86
7.4.130.0150.00616.67
7.4.120.0120.00616.76
7.4.110.0070.01016.80
7.4.100.0120.01216.77
7.4.90.0060.01216.86
7.4.80.0150.00619.39
7.4.70.0150.00616.70
7.4.60.0130.00716.47
7.4.50.0090.00516.79
7.4.40.0080.00816.71
7.4.30.0130.00316.82
7.4.00.0000.01715.20
7.3.330.0030.00313.33
7.3.320.0000.00513.36
7.3.310.0070.00016.55
7.3.300.0000.00716.38
7.3.290.0060.00016.53
7.3.280.0090.00816.51
7.3.270.0180.00017.40
7.3.260.0030.01516.71
7.3.250.0120.00816.65
7.3.240.0090.00816.47
7.3.230.0090.00916.84
7.3.210.0060.01116.85
7.3.200.0140.00816.61
7.3.190.0170.00316.39
7.3.180.0080.00816.70
7.3.170.0080.00816.66
7.3.160.0090.00616.45
7.3.00.0030.00916.60
7.2.330.0120.00916.83
7.2.320.0130.00716.48
7.2.310.0110.00816.66
7.2.300.0120.00416.56
7.2.290.0070.01016.56
7.2.130.0030.00616.73
7.2.120.0070.00717.06
7.2.110.0060.00617.04
7.2.100.0120.00017.13
7.2.90.0000.01017.07
7.2.80.0040.01117.18
7.2.70.0000.01417.02
7.2.60.0040.01017.08
7.2.50.0060.00916.89
7.2.40.0030.01417.02
7.2.30.0000.01216.87
7.2.20.0030.01217.04
7.2.10.0040.01117.20
7.2.00.0040.00717.08
7.1.250.0070.00716.13
7.1.240.0000.01115.91
7.1.230.0000.01416.06
7.1.220.0080.00815.79
7.1.210.0030.01015.77
7.1.200.0030.01115.94
7.1.190.0130.00016.13
7.1.180.0000.00915.99
7.1.170.0090.00015.99
7.1.160.0060.00616.06
7.1.150.0140.00015.94
7.1.140.0050.00516.13
7.1.130.0070.00716.01
7.1.120.0000.01316.13
7.1.110.0070.00715.62
7.1.100.0040.01516.09
7.1.90.0110.00416.11
7.1.80.0060.00615.91
7.1.70.0750.01115.70
7.1.60.0990.01124.55
7.1.50.0230.01224.50
7.1.40.0830.00924.15
7.1.30.0880.01124.49
7.1.20.0920.01224.57
7.1.10.0360.00815.46
7.1.00.0910.01315.56
7.0.330.0100.00315.33
7.0.320.0040.00815.67
7.0.310.0070.00715.38
7.0.300.0060.00615.52
7.0.290.0060.00615.57
7.0.280.0060.00315.18
7.0.270.0110.00015.52
7.0.260.0030.00715.50
7.0.250.0100.00315.39
7.0.240.0050.00515.63
7.0.230.0000.01415.49
7.0.220.0000.00815.71
7.0.210.0000.00815.44
7.0.200.0800.01015.14
7.0.190.0940.00815.37
7.0.180.0210.00814.92
7.0.170.0270.00915.06
7.0.160.0680.01215.16
7.0.150.0710.00815.08
7.0.140.0840.00715.20
7.0.130.0970.01215.19
7.0.120.0080.01115.17
7.0.110.0060.01015.27
7.0.100.0490.00915.26
7.0.90.0160.00915.27
7.0.80.0090.00815.31
7.0.70.0240.01015.06
7.0.60.0730.01114.97
7.0.50.0920.01215.23
7.0.40.0860.01314.29
7.0.30.0890.01014.27
7.0.20.0810.01014.33
7.0.10.0760.00914.40
7.0.00.0740.01114.28
5.6.380.0060.00614.11

preferences:
36.71 ms | 401 KiB | 5 Q