3v4l.org

run code in 300+ PHP versions simultaneously
<?php $category = '{"9":{"id":"9","btc_mlm_user_id":"0","lft":"1","rht":"16","lvl":"0","name":"Root","created":"2017-06-27 05:56:11","modified":"2017-06-27 05:56:11","first_name":"","last_name":"","username":""},"42":{"id":"42","btc_mlm_user_id":"25","lft":"2","rht":"13","lvl":"1","name":"naresh","created":"2017-11-02 10:22:24","modified":"2017-11-02 10:22:24","first_name":"","last_name":"","username":"naresh"},"44":{"id":"44","btc_mlm_user_id":"27","lft":"3","rht":"4","lvl":"2","name":"rahul1","created":"2017-11-02 10:25:53","modified":"2017-11-02 10:25:53","first_name":"","last_name":"","username":"rahul1"},"45":{"id":"45","btc_mlm_user_id":"28","lft":"5","rht":"6","lvl":"2","name":"rahul123","created":"2017-11-02 10:27:19","modified":"2017-11-02 10:27:19","first_name":"","last_name":"","username":"rahul123"},"46":{"id":"46","btc_mlm_user_id":"29","lft":"7","rht":"12","lvl":"2","name":"kapil1","created":"2017-11-02 10:28:20","modified":"2017-11-02 10:28:20","first_name":"","last_name":"","username":"kapil1"},"47":{"id":"47","btc_mlm_user_id":"30","lft":"8","rht":"11","lvl":"3","name":"priya12","created":"2017-11-02 10:30:30","modified":"2017-11-02 10:30:30","first_name":"","last_name":"","username":"priya12"},"48":{"id":"48","btc_mlm_user_id":"31","lft":"9","rht":"10","lvl":"4","name":"amit12","created":"2017-11-02 10:32:00","modified":"2017-11-02 10:32:00","first_name":"","last_name":"","username":"amit12"},"43":{"id":"43","btc_mlm_user_id":"26","lft":"14","rht":"15","lvl":"1","name":"roshan","created":"2017-11-02 10:24:27","modified":"2017-11-02 10:24:27","first_name":"","last_name":"","username":"roshan"}}'; $t = []; function tree($data, $left = 0, $right = null) { $tree = array(); foreach ($data as $key => $value) { if ($value['lft'] == $left + 1 && (is_null($right) || $value['rht'] < $right)) { $child = []; $child['text'] = ['name' => $value['name']]; $childTree = tree($data, $value['lft'], $value['rht']); if (!empty($childTree)) { $child['children'] = $childTree; } $tree[] = $child; $left = $value['rht']; } } return $tree; } $tree = tree(json_decode($category, true))[0]; print_r($tree); echo json_encode($tree);

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.0120.00318.15
8.3.60.0150.00016.63
8.3.50.0120.00517.55
8.3.40.0030.01319.02
8.3.30.0150.00018.84
8.3.20.0050.00320.38
8.3.10.0030.00723.39
8.3.00.0080.00023.67
8.2.190.0130.00616.58
8.2.180.0060.00916.88
8.2.170.0120.00322.96
8.2.160.0130.00320.45
8.2.150.0080.00025.66
8.2.140.0030.00724.66
8.2.130.0080.00026.16
8.2.120.0060.00320.79
8.2.110.0110.00022.25
8.2.100.0060.00617.84
8.2.90.0030.00519.46
8.2.80.0040.00417.97
8.2.70.0070.00317.93
8.2.60.0080.00018.05
8.2.50.0000.00818.16
8.2.40.0080.00020.42
8.2.30.0060.00321.14
8.2.20.0000.00818.11
8.2.10.0000.00818.20
8.2.00.0000.00818.16
8.1.280.0140.00725.92
8.1.270.0040.00423.84
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0060.00319.15
8.1.230.0060.00622.13
8.1.220.0000.00817.79
8.1.210.0100.00019.04
8.1.200.0030.00517.48
8.1.190.0080.00017.23
8.1.180.0040.00418.10
8.1.170.0080.00018.96
8.1.160.0040.00418.84
8.1.150.0040.00420.59
8.1.140.0000.00917.67
8.1.130.0070.00018.81
8.1.120.0040.00417.44
8.1.110.0000.00817.36
8.1.100.0080.00017.39
8.1.90.0040.00417.46
8.1.80.0000.00717.47
8.1.70.0030.00317.53
8.1.60.0040.00417.52
8.1.50.0000.00917.59
8.1.40.0000.00817.54
8.1.30.0040.00417.75
8.1.20.0040.00417.67
8.1.10.0040.00417.52
8.1.00.0000.00817.50
8.0.300.0060.00319.90
8.0.290.0060.00316.88
8.0.280.0070.00018.42
8.0.270.0060.00317.37
8.0.260.0070.00016.86
8.0.250.0000.00717.05
8.0.240.0000.00717.07
8.0.230.0000.00817.07
8.0.220.0040.00416.93
8.0.210.0000.00717.04
8.0.200.0030.00317.03
8.0.190.0060.00317.05
8.0.180.0040.00417.00
8.0.170.0000.00717.00
8.0.160.0040.00317.07
8.0.150.0070.00016.89
8.0.140.0030.00716.84
8.0.130.0030.00313.42
8.0.120.0050.00316.99
8.0.110.0040.00417.04
8.0.100.0000.00816.87
8.0.90.0040.00417.03
8.0.80.0000.01417.01
8.0.70.0000.00717.10
8.0.60.0040.00416.82
8.0.50.0040.00416.88
8.0.30.0080.01017.17
8.0.20.0150.00717.40
8.0.10.0030.00617.17
8.0.00.0110.00716.96
7.4.330.0020.00216.83
7.4.320.0040.00416.64
7.4.300.0000.00716.51
7.4.290.0030.00316.64
7.4.280.0030.00516.66
7.4.270.0030.00316.61
7.4.260.0000.00716.53
7.4.250.0000.00716.52
7.4.240.0000.00716.61
7.4.230.0030.00316.66
7.4.220.0170.00316.66
7.4.210.0160.00016.59
7.4.200.0030.00316.65
7.4.160.0130.00316.41
7.4.150.0070.01117.40
7.4.140.0100.01017.86
7.4.130.0030.01716.63
7.4.120.0110.00716.55
7.4.110.0130.00716.39
7.4.100.0090.00916.67
7.4.90.0130.01016.55
7.4.80.0130.00319.39
7.4.70.0130.01016.43
7.4.60.0060.01116.63
7.4.50.0040.00816.68
7.4.40.0070.01016.53
7.4.30.0150.00616.50
7.4.00.0100.00714.98
7.3.330.0030.00313.36
7.3.320.0050.00013.40
7.3.310.0070.00016.44
7.3.300.0030.00316.39
7.3.290.0070.00916.40
7.3.280.0090.00716.38
7.3.270.0140.01017.40
7.3.260.0070.00916.41
7.3.250.0090.01016.65
7.3.240.0090.00816.45
7.3.230.0030.01316.41
7.3.210.0130.00316.41
7.3.200.0110.01116.41
7.3.190.0120.00416.48
7.3.180.0070.01116.47
7.3.170.0120.00616.63
7.3.160.0090.00616.35
7.2.330.0090.01216.64
7.2.320.0200.00316.83
7.2.310.0080.00816.83
7.2.300.0100.00716.49
7.2.290.0110.00816.84
7.2.60.0030.00716.80
7.1.200.0030.00315.68
7.1.110.0100.00918.46
7.1.100.0030.01418.33
7.1.90.0100.00718.21
7.1.80.0100.01117.97
7.1.70.0050.01417.13
7.1.60.0160.01635.04
7.1.50.0160.01634.65
7.1.40.0130.02834.53
7.1.30.0300.01034.41
7.1.20.0280.01234.62
7.1.10.0110.00816.56
7.1.00.0040.01116.56
7.0.250.0080.01217.41
7.0.240.0130.00717.95
7.0.230.0160.01517.70
7.0.220.0120.00917.74
7.0.210.0100.01416.78
7.0.200.0180.00416.76
7.0.190.0110.01716.70
7.0.180.0170.00616.06
7.0.170.0060.01616.43
7.0.160.0120.01216.37
7.0.150.0030.01916.18
7.0.140.0060.01516.52
7.0.130.0090.01616.42
7.0.120.0100.00916.74
7.0.110.0050.01516.29
7.0.100.0080.00916.55
7.0.90.0000.01816.20
7.0.80.0110.01116.43
7.0.70.0090.01816.36
7.0.60.0080.01216.17
7.0.50.0110.01116.40
7.0.40.0160.01016.35
7.0.30.0090.01216.55
7.0.20.0120.00716.36
7.0.10.0060.01416.18
7.0.00.0100.01016.36

preferences:
29.38 ms | 401 KiB | 5 Q