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)) { $tree[$key]['text'] = ['name' => $value['name']]; $tree[$key]['children'] = tree($data, $value['lft'], $value['rht']); $left = $value['rht']; } } return $tree; } $tree = tree(json_decode($category, true)); 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.0090.00616.88
8.3.60.0100.01317.00
8.3.50.0110.00717.51
8.3.40.0110.00418.84
8.3.30.0000.01518.84
8.3.20.0000.00820.35
8.3.10.0080.00023.57
8.3.00.0040.00423.66
8.2.190.0060.01016.75
8.2.180.0070.01118.29
8.2.170.0140.00318.89
8.2.160.0100.00322.96
8.2.150.0080.00025.66
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0040.00420.71
8.2.110.0030.00720.56
8.2.100.0040.00818.03
8.2.90.0050.00317.75
8.2.80.0080.00018.79
8.2.70.0040.00417.63
8.2.60.0050.00317.75
8.2.50.0080.00018.04
8.2.40.0040.00419.35
8.2.30.0080.00019.42
8.2.20.0040.00718.27
8.2.10.0040.00418.16
8.2.00.0000.00818.16
8.1.280.0140.00325.92
8.1.270.0080.00023.82
8.1.260.0070.00026.35
8.1.250.0030.00528.09
8.1.240.0090.00619.21
8.1.230.0070.00417.82
8.1.220.0040.00417.77
8.1.210.0000.00818.77
8.1.200.0060.00317.24
8.1.190.0040.00417.23
8.1.180.0110.00218.10
8.1.170.0070.00017.62
8.1.160.0000.00718.91
8.1.150.0040.00418.84
8.1.140.0080.00017.74
8.1.130.0080.00318.82
8.1.120.0030.00517.39
8.1.110.0050.00217.54
8.1.100.0100.00017.48
8.1.90.0040.00417.49
8.1.80.0050.00517.38
8.1.70.0000.00717.47
8.1.60.0050.00517.59
8.1.50.0090.00017.58
8.1.40.0030.00617.44
8.1.30.0050.00317.71
8.1.20.0060.00317.67
8.1.10.0050.00317.50
8.1.00.0060.00317.43
8.0.300.0040.00420.49
8.0.290.0000.00916.75
8.0.280.0030.00318.40
8.0.270.0030.00317.36
8.0.260.0040.00416.99
8.0.250.0030.00317.05
8.0.240.0030.00316.96
8.0.230.0090.00016.93
8.0.220.0030.00317.05
8.0.210.0000.00716.96
8.0.200.0060.00617.03
8.0.190.0040.00416.96
8.0.180.0030.00516.89
8.0.170.0040.00416.95
8.0.160.0040.00316.95
8.0.150.0040.00416.89
8.0.140.0080.00016.91
8.0.130.0030.00313.41
8.0.120.0030.00616.97
8.0.110.0000.00716.92
8.0.100.0000.00917.03
8.0.90.0000.00817.11
8.0.80.0110.00416.95
8.0.70.0020.00517.05
8.0.60.0070.00016.98
8.0.50.0030.00517.04
8.0.30.0120.01017.08
8.0.20.0130.01017.40
8.0.10.0020.00516.89
8.0.00.0060.01316.96
7.4.330.0000.00516.71
7.4.320.0000.00716.54
7.4.300.0030.00316.61
7.4.290.0040.00416.52
7.4.280.0060.00316.44
7.4.270.0070.00016.61
7.4.260.0000.00716.57
7.4.250.0040.00416.61
7.4.240.0040.00416.69
7.4.230.0070.00016.42
7.4.220.0130.00716.66
7.4.210.0030.01316.64
7.4.200.0040.00216.71
7.4.160.0100.00516.49
7.4.150.0120.00617.40
7.4.140.0110.01017.86
7.4.130.0160.00616.59
7.4.120.0100.00916.57
7.4.110.0100.01316.51
7.4.100.0100.00716.62
7.4.90.0090.00916.47
7.4.80.0120.00619.39
7.4.70.0060.01216.58
7.4.60.0060.00916.44
7.4.50.0120.00316.22
7.4.40.0060.01016.39
7.4.30.0100.01016.47
7.4.00.0000.01315.25
7.3.330.0030.00313.39
7.3.320.0000.00613.27
7.3.310.0040.00416.22
7.3.300.0000.00716.35
7.3.290.0080.00816.38
7.3.280.0080.00916.38
7.3.270.0090.00917.40
7.3.260.0090.00816.54
7.3.250.0120.00716.45
7.3.240.0110.01116.54
7.3.230.0130.00416.33
7.3.210.0040.01316.65
7.3.200.0160.00616.34
7.3.190.0100.00716.52
7.3.180.0060.01016.54
7.3.170.0060.01616.46
7.3.160.0130.00716.62
7.3.10.0040.00716.83
7.3.00.0060.00716.70
7.2.330.0090.00916.93
7.2.320.0090.00816.50
7.2.310.0060.01216.78
7.2.300.0110.00916.86
7.2.290.0070.01016.84
7.2.130.0020.01317.05
7.2.120.0020.01016.93
7.2.110.0040.00616.84
7.2.100.0040.00716.82
7.2.90.0040.00917.03
7.2.80.0080.00616.98
7.2.70.0040.01116.90
7.2.60.0070.00716.94
7.2.50.0060.01016.74
7.2.40.0050.00516.81
7.2.30.0020.00817.07
7.2.20.0060.00517.03
7.2.10.0090.00516.86
7.2.00.0040.00816.97
7.1.250.0040.00815.88
7.1.240.0030.00616.02
7.1.230.0000.01315.78
7.1.220.0040.01115.76
7.1.210.0100.00315.77
7.1.200.0050.00815.68
7.1.190.0040.01015.61
7.1.180.0000.01315.74
7.1.170.0090.00015.86
7.1.160.0000.01015.83
7.1.150.0100.00315.62
7.1.140.0070.00315.57
7.1.130.0080.00415.70
7.1.120.0040.01116.05
7.1.110.0080.01017.55
7.1.100.0070.01017.45
7.1.90.0050.01017.53
7.1.80.0060.00917.50
7.1.70.0050.00916.81
7.1.60.0200.01230.13
7.1.50.0150.01330.12
7.1.40.0130.01729.88
7.1.30.0160.01329.77
7.1.20.0170.01729.96
7.1.10.0090.00916.49
7.1.00.0040.01016.31
7.0.330.0080.00815.04
7.0.320.0070.00715.23
7.0.310.0070.01015.09
7.0.300.0130.00715.11
7.0.290.0070.00415.12
7.0.280.0140.00315.03
7.0.270.0160.00015.43
7.0.260.0110.00415.39
7.0.250.0110.01217.17
7.0.240.0160.01217.29
7.0.230.0110.01017.19
7.0.220.0080.01217.08
7.0.210.0080.01116.39
7.0.200.0110.00916.35
7.0.190.0140.00716.24
7.0.180.0090.00915.97
7.0.170.0100.01516.08
7.0.160.0120.01116.13
7.0.150.0090.01216.20
7.0.140.0110.01016.14
7.0.130.0100.01216.26
7.0.120.0110.00916.26
7.0.110.0090.01216.12
7.0.100.0090.01616.04
7.0.90.0130.01116.15
7.0.80.0100.01216.12
7.0.70.0110.01015.93
7.0.60.0090.01315.87
7.0.50.0100.01216.19
7.0.40.0120.01015.66
7.0.30.0140.01115.67
7.0.20.0160.00815.59
7.0.10.0060.01215.58
7.0.00.0110.01115.67
5.6.380.0070.01014.34

preferences:
32.39 ms | 401 KiB | 5 Q