3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json_str='{ "code": 200, "message": "操作成功", "data": [ { "id": 1, "goods_id": 1, "property_name_id": 1, "property_value_id": 1, "property_name": { "title": "份量", "is_sale": true }, "property_value": { "id": 1, "value": "小份", "image": "" } }, { "id": 2, "goods_id": 1, "property_name_id": 1, "property_value_id": 2, "property_name": { "title": "份量", "is_sale": true }, "property_value": { "id": 2, "value": "中份", "image": "" } }, { "id": 3, "goods_id": 1, "property_name_id": 2, "property_value_id": 4, "property_name": { "title": "温度", "is_sale": true }, "property_value": { "id": 4, "value": "常温", "image": "" } }, { "id": 4, "goods_id": 1, "property_name_id": 2, "property_value_id": 5, "property_name": { "title": "温度", "is_sale": true }, "property_value": { "id": 5, "value": "加冰", "image": "" } } ] }'; $obj = json_decode($json_str); $data = []; foreach($obj->data as $v){ $nid=$v->property_name_id; if(!array_key_exists($nid,$data)){ $o = new stdclass; $o->property_id = $v->property_name_id; $o->property_name = $v->property_name->title; $o->is_sale= $v->property_name->is_sale ; $data[$nid]=$o; } $data[$nid]->items[]=$v->property_value; } $obj->data = array_values($data); print_r($obj); //echo json_encode($obj);

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.0000.01516.88
8.3.60.0080.00818.56
8.3.50.0130.00716.30
8.3.40.0120.00318.88
8.3.30.0120.00318.89
8.3.20.0000.00820.94
8.3.10.0000.00720.34
8.3.00.0030.01223.57
8.2.190.0060.01216.58
8.2.180.0140.00718.29
8.2.170.0120.00622.96
8.2.160.0210.00320.39
8.2.150.0090.00024.18
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0040.00420.02
8.2.110.0050.00521.04
8.2.100.0090.00317.84
8.2.90.0040.00418.22
8.2.80.0000.00720.49
8.2.70.0000.00818.04
8.2.60.0050.00318.22
8.2.50.0000.00818.10
8.2.40.0060.00319.53
8.2.30.0070.00019.45
8.2.20.0000.00918.15
8.2.10.0040.00419.35
8.2.00.0040.00419.39
8.1.280.0060.01225.92
8.1.270.0040.00420.70
8.1.260.0070.00026.35
8.1.250.0070.00028.09
8.1.240.0060.00323.78
8.1.230.0080.00420.97
8.1.220.0030.00517.74
8.1.210.0040.00418.85
8.1.200.0030.00617.23
8.1.190.0030.00617.23
8.1.180.0060.00319.04
8.1.170.0000.00818.63
8.1.160.0040.00419.07
8.1.150.0000.00818.91
8.1.140.0050.00322.21
8.1.130.0040.00417.44
8.1.120.0040.00417.40
8.1.110.0060.00317.46
8.1.100.0030.00517.44
8.1.90.0000.00717.47
8.1.80.0030.00517.38
8.1.70.0030.00317.46
8.1.60.0030.00517.60
8.1.50.0030.00517.60
8.1.40.0030.00617.52
8.1.30.0050.00317.60
8.1.20.0030.00617.56
8.1.10.0030.00617.58
8.1.00.0060.00317.42
8.0.300.0040.00419.85
8.0.290.0000.00816.63
8.0.280.0030.00318.34
8.0.270.0080.00016.85
8.0.260.0060.00016.85
8.0.250.0000.00716.99
8.0.240.0060.00317.00
8.0.230.0040.00417.00
8.0.220.0070.00016.93
8.0.210.0040.00416.91
8.0.200.0030.00316.87
8.0.190.0000.00716.89
8.0.180.0080.00016.95
8.0.170.0040.00416.98
8.0.160.0050.00516.84
8.0.150.0050.00216.96
8.0.140.0040.00416.92
8.0.130.0000.00613.34
8.0.120.0040.00416.77
8.0.110.0040.00416.93
8.0.100.0040.00416.70
8.0.90.0000.00816.88
8.0.80.0100.00616.86
8.0.70.0000.00816.87
8.0.60.0080.00016.87
8.0.50.0040.00417.03
8.0.30.0100.00717.15
8.0.20.0090.01017.14
8.0.10.0030.00517.03
8.0.00.0130.00316.73
7.4.330.0050.00015.55
7.4.320.0000.00616.63
7.4.300.0030.00316.60
7.4.290.0000.00716.52
7.4.280.0080.00016.62
7.4.270.0090.00016.43
7.4.260.0030.00313.27
7.4.250.0000.00716.51
7.4.240.0020.00516.55
7.4.230.0030.00316.39
7.4.220.0020.00516.43
7.4.210.0080.01016.59
7.4.200.0070.00016.56
7.4.130.0140.01116.65
7.4.120.0060.01216.43
7.4.110.0040.01316.50
7.4.100.0070.01016.70
7.4.90.0200.00316.67
7.4.80.0030.01419.39
7.4.70.0100.00716.52
7.4.60.0110.00616.49
7.4.50.0040.01116.32
7.4.40.0040.01116.43
7.4.00.0030.00915.18
7.3.330.0070.00016.39
7.3.320.0030.00313.07
7.3.310.0000.00716.20
7.3.300.0030.00316.38
7.3.290.0060.00816.31
7.3.280.0070.01016.30
7.3.260.0110.00816.51
7.3.240.0080.00916.41
7.3.230.0130.00316.39
7.3.210.0070.01016.32
7.3.200.0120.00416.39
7.3.190.0130.00916.36
7.3.180.0070.01016.25
7.3.170.0130.00316.39
7.3.160.0070.01016.52
7.3.120.0030.01015.04
7.3.110.0060.00914.84
7.3.100.0090.00314.96
7.3.90.0100.00614.80
7.3.80.0060.00915.01
7.3.70.0050.01015.00
7.3.60.0100.00315.01
7.3.50.0030.01214.81
7.3.40.0050.01014.71
7.3.30.0070.01014.84
7.3.20.0040.01314.93
7.3.10.0220.00614.85
7.3.00.0050.00915.00
7.2.330.0030.01416.83
7.2.320.0100.01316.51
7.2.310.0030.01316.82
7.2.300.0130.01216.85
7.2.290.0100.00616.68
7.2.250.0080.00914.90
7.2.240.0120.00314.60
7.2.230.0130.00314.84
7.2.220.0070.01015.25
7.2.210.0030.01515.25
7.2.200.0050.01014.96
7.2.190.0040.01115.07
7.2.180.0030.01015.04
7.2.170.0080.00815.34
7.1.330.0090.00913.88
7.1.320.0090.00614.03
7.1.310.0050.01014.13
7.1.300.0080.00414.07
7.1.290.0100.00514.03
7.1.280.0000.01413.86
7.1.270.0030.01013.81
7.1.260.0060.01113.94

preferences:
48.2 ms | 401 KiB | 5 Q