3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json_string = '{"error_code":0,"error_message":"","return_data":{"items":[{"id":462,"users":"1,36,38"},{"id":462,"users":"1,4"}]}}'; $res = json_decode($json_string, 1); $items = $res['return_data']['items']; unset($res['return_data']['items']); // unset it first, to replace a new one $new_items = array(); foreach ($items as $key => $item) { $usersArray['id'] = $item['id']; $usersArray['users'] = array(); //create a new Array $usersIdArray = explode(',', $item['users']); foreach ($usersIdArray as $key => $user) { $usersArray['users'][] = array('user_id' => $user); // another level ^ } $res['return_data']['items'][] = $usersArray; } echo json_encode($res, JSON_PRETTY_PRINT);

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.130.0080.00018.30
8.3.120.0040.00420.59
8.3.110.0120.00320.94
8.3.100.0040.00716.86
8.3.90.0080.00026.77
8.3.80.0000.00916.63
8.3.70.0140.00416.75
8.3.60.0130.00618.53
8.3.50.0160.00317.08
8.3.40.0060.01218.68
8.3.30.0090.00618.78
8.3.20.0050.00319.33
8.3.10.0000.00819.29
8.3.00.0000.00723.61
8.2.250.0030.00716.91
8.2.240.0080.00017.28
8.2.230.0070.01122.58
8.2.220.0060.00324.06
8.2.210.0040.00426.77
8.2.200.0060.00316.63
8.2.190.0070.01316.58
8.2.180.0070.00725.92
8.2.170.0060.00918.70
8.2.160.0110.00422.96
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0140.00026.16
8.2.120.0080.00020.81
8.2.110.0060.00319.36
8.2.100.0100.00317.84
8.2.90.0050.00317.84
8.2.80.0000.00819.18
8.2.70.0040.00417.80
8.2.60.0080.00017.93
8.2.50.0080.00018.10
8.2.40.0000.00819.51
8.2.30.0030.00519.53
8.2.20.0040.00417.99
8.2.10.0040.00418.12
8.2.00.0030.00319.38
8.1.300.0160.00019.46
8.1.290.0000.00930.84
8.1.280.0140.00025.92
8.1.270.0030.00321.90
8.1.260.0000.00826.35
8.1.250.0000.00728.09
8.1.240.0120.00622.05
8.1.230.0000.01120.88
8.1.220.0000.00817.74
8.1.210.0060.00318.92
8.1.200.0100.00017.48
8.1.190.0060.00317.35
8.1.180.0040.00418.10
8.1.170.0050.00318.57
8.1.160.0040.00418.89
8.1.150.0000.00818.77
8.1.140.0050.00217.71
8.1.130.0060.00319.13
8.1.120.0030.00517.45
8.1.110.0080.00017.45
8.1.100.0040.00417.49
8.1.90.0030.00617.32
8.1.80.0030.00317.46
8.1.70.0000.00817.42
8.1.60.0060.00317.59
8.1.50.0040.00417.53
8.1.40.0030.00617.55
8.1.30.0030.00517.59
8.1.20.0000.00817.64
8.1.10.0070.00017.60
8.1.00.0040.00417.41
8.0.300.0000.00720.16
8.0.290.0060.00316.63
8.0.280.0000.00718.36
8.0.270.0000.00716.82
8.0.260.0000.00717.18
8.0.250.0030.00316.92
8.0.240.0040.00416.98
8.0.230.0060.00316.86
8.0.220.0080.00216.93
8.0.210.0000.00716.94
8.0.200.0000.00717.01
8.0.190.0000.00716.92
8.0.180.0080.00016.79
8.0.170.0000.01116.91
8.0.160.0040.00416.94
8.0.150.0000.00716.87
8.0.140.0030.00516.86
8.0.130.0000.00613.33
8.0.120.0030.00516.77
8.0.110.0000.00716.97
8.0.100.0000.00716.68
8.0.90.0030.00317.02
8.0.80.0050.01416.92
8.0.70.0040.00416.89
8.0.60.0000.00716.77
8.0.50.0030.00516.72
8.0.30.0080.01317.01
8.0.20.0110.00917.40
8.0.10.0000.00817.09
8.0.00.0080.01116.95
7.4.330.0020.00215.55
7.4.320.0060.00016.62
7.4.300.0000.00616.51
7.4.290.0000.00716.50
7.4.280.0000.00716.60
7.4.270.0060.00316.59
7.4.260.0000.00716.36
7.4.250.0040.00416.57
7.4.240.0030.00316.42
7.4.230.0000.00716.61
7.4.220.0080.00016.65
7.4.210.0040.01216.51
7.4.200.0000.00716.50
7.4.160.0080.01016.61
7.4.140.0130.00617.86
7.4.130.0070.01116.34
7.4.120.0110.00916.57
7.4.110.0100.01316.39
7.4.100.0100.00716.43
7.4.90.0070.01016.52
7.4.80.0070.01119.39
7.4.70.0130.00316.49
7.4.60.0060.01516.58
7.4.50.0060.00916.60
7.4.40.0150.00316.63
7.4.00.0070.01015.26
7.3.330.0000.00513.04
7.3.320.0050.00013.20
7.3.310.0000.00716.16
7.3.300.0070.00016.41
7.3.290.0000.00716.22
7.3.280.0090.01016.29
7.3.260.0110.00716.42
7.3.240.0080.00916.51
7.3.230.0130.00316.39
7.3.210.0080.00816.63
7.3.200.0130.00316.31
7.3.190.0090.01616.54
7.3.180.0120.00416.66
7.3.170.0110.01116.21
7.3.160.0160.00316.48
7.3.120.0110.00714.85
7.3.110.0000.01414.74
7.3.100.0110.00315.01
7.3.90.0030.01215.05
7.3.80.0100.00714.96
7.3.70.0070.01014.92
7.3.60.0030.00914.71
7.3.50.0060.00614.98
7.3.40.0030.00914.84
7.3.30.0140.00014.66
7.3.20.0000.01716.59
7.3.10.0080.00616.64
7.3.00.0060.00916.74
7.2.330.0150.00616.60
7.2.320.0070.01016.60
7.2.310.0040.01716.85
7.2.300.0090.01216.77
7.2.290.0150.00316.66
7.2.240.0070.00715.25
7.2.230.0030.01315.12
7.2.220.0040.01215.24
7.2.210.0030.01215.36
7.2.200.0040.00714.96
7.2.190.0060.00615.17
7.2.180.0030.00915.02
7.2.170.0070.00714.80
7.2.160.0060.01214.91
7.2.150.0050.01017.00
7.2.140.0040.02117.01
7.2.130.0040.01516.96
7.2.120.0080.01016.83
7.2.110.0080.01016.66
7.2.100.0050.01016.84
7.2.90.0090.00716.84
7.2.80.0090.00517.08
7.2.70.0060.01017.03
7.2.60.0090.01016.22
7.2.50.0070.00916.21
7.2.40.0080.00916.43
7.2.30.0070.00816.36
7.2.20.0080.01016.31
7.2.10.0140.00816.31
7.2.00.0090.00716.97
7.1.330.0060.00915.99
7.1.320.0090.00615.66
7.1.310.0030.01015.59
7.1.300.0090.00315.75
7.1.290.0100.00715.77
7.1.280.0060.00615.95
7.1.270.0030.01015.97
7.1.260.0040.01615.89
7.1.250.0040.01315.65
7.1.200.0030.01015.88
7.1.170.0300.01414.05
7.1.160.0180.00413.81
7.1.150.0120.01213.86
7.1.140.0060.01214.07
7.1.130.0110.00714.10
7.1.120.0060.00615.89
7.1.110.0030.01315.81
7.1.100.0030.01015.75
7.1.90.0150.00715.70
7.1.80.0040.00815.76
7.1.70.0080.00815.73
7.1.60.0330.01333.81
7.1.50.0210.01733.48
7.1.40.0250.00633.62
7.1.30.0170.01433.86
7.1.20.0140.01733.58
7.1.10.0080.00415.68
7.1.00.0040.00815.78

preferences:
28.26 ms | 403 KiB | 5 Q