3v4l.org

run code in 300+ PHP versions simultaneously
<?php $reporting_data = array( 'category_name' => '33287*100*prescription*1,32457*1250*lab*1,32459*1500*lab*1,32460*400*lab*1,32461*600*lab*1,32468*950*lab*1,32470*950*lab*1,33291*2500*lab*1,33292*2500*lab*1,47516*2000*lab*1,49209*0*lab*1,56835*2400*lab*1,56836*2400*lab*1', 'patient' => '28370', 'date' => 1643030497, 'ref' => '371', ); // Create array of objects $reporting_data_as_objects[] = (object)$reporting_data; $results = []; foreach ($reporting_data_as_objects as &$obj) { // Setup base data that is shared across all items $obj->reception_data_sum = 0; $obj->references_data_sum = 0; $obj->actual_price = 0; $category_names = explode(',', $obj->category_name); // Loop over the comma-delimited parts of category_name foreach ($category_names as $category_name) { // Clone our template object $tmp = clone $obj; // The second item of the asterisk-delimted field is the price // We used $_ to indicate that we aren't interested in the first item. list($_, $sale_value) = explode('*', $category_name); // Set object-specific fields on our clone $tmp->category_name = $category_name; $tmp->actual_price = (int)$sale_value; // Add the clone to the array $results[] = $tmp; } } // Always unset by-ref variables of a foreach unset($obj); print_r($results);

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.5.10.0100.00718.74
8.5.00.0140.00820.04
8.4.150.0020.00114.05
8.4.140.0160.00617.46
8.4.130.0140.00619.35
8.4.120.0100.01022.46
8.4.110.0100.00518.88
8.4.100.0120.01218.85
8.4.90.0100.00818.96
8.4.80.0120.00818.97
8.4.70.0080.01019.36
8.4.60.0160.00518.79
8.4.50.0060.00922.71
8.4.40.0080.00317.56
8.4.30.0130.00720.14
8.4.20.0190.00319.62
8.4.10.0060.00319.50
8.3.280.0020.00014.05
8.3.270.0140.00516.91
8.3.260.0090.01116.62
8.3.250.0120.00617.04
8.3.240.0060.00416.38
8.3.230.0120.00616.40
8.3.220.0060.00317.20
8.3.210.0130.00516.61
8.3.200.0050.00316.76
8.3.190.0070.01217.45
8.3.180.0070.01218.43
8.3.170.0120.00618.94
8.3.160.0090.00918.68
8.3.150.0100.01019.09
8.3.140.0040.00421.03
8.3.130.0150.00018.46
8.3.120.0000.01218.87
8.3.110.0080.00020.94
8.3.100.0030.01024.06
8.3.90.0030.00726.77
8.3.80.0090.00018.34
8.3.70.0070.00716.84
8.3.60.0120.00316.48
8.3.50.0090.00920.02
8.3.40.0110.00419.82
8.3.30.0110.00418.81
8.3.20.0000.00824.18
8.3.10.0000.00824.66
8.3.00.0050.00326.16
8.2.290.0130.00620.33
8.2.280.0100.00918.61
8.2.270.0130.00616.59
8.2.260.0100.00617.27
8.2.250.0080.00018.32
8.2.240.0060.00917.00
8.2.230.0000.00922.58
8.2.220.0100.00737.54
8.2.210.0040.01126.77
8.2.200.0080.00016.50
8.2.190.0140.00316.75
8.2.180.0110.00725.92
8.2.170.0040.01118.96
8.2.160.0110.00722.96
8.2.150.0110.00325.66
8.2.140.0000.00724.66
8.2.130.0050.00326.16
8.2.120.0040.00426.16
8.2.110.0030.00622.07
8.2.100.0080.00417.90
8.2.90.0070.00019.21
8.2.80.0060.00317.97
8.2.70.0030.00617.75
8.2.60.0050.00317.93
8.2.50.0080.00318.07
8.2.40.0040.00420.01
8.2.30.0040.00418.02
8.2.20.0030.00720.32
8.2.10.0040.00417.82
8.2.00.0000.00719.22
8.1.330.0130.00616.00
8.1.320.0120.00616.27
8.1.310.0150.00316.84
8.1.300.0000.00917.87
8.1.290.0060.00318.88
8.1.280.0110.00725.92
8.1.270.0080.00023.99
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0000.00920.63
8.1.230.0120.00017.76
8.1.220.0000.00717.74
8.1.210.0040.00418.77
8.1.200.0100.00017.46
8.1.190.0060.00317.36
8.1.180.0060.00318.10
8.1.170.0050.00318.66
8.1.160.0000.00718.91
8.1.150.0000.00718.71
8.1.140.0040.00417.37
8.1.130.0040.00417.47
8.1.120.0000.00717.36
8.1.110.0040.00417.36
8.1.100.0000.00817.50
8.1.90.0000.00717.30
8.1.80.0070.00017.43
8.1.70.0040.00417.48
8.1.60.0040.00417.59
8.1.50.0050.00317.56
8.1.40.0040.00417.53
8.1.30.0030.00517.63
8.1.20.0270.00417.63
8.1.10.0160.00917.49
8.1.00.0170.00917.50
8.0.300.0070.00018.77
8.0.290.0050.00316.88
8.0.280.0000.00920.17
8.0.270.0040.00417.89
8.0.260.0000.00616.82
8.0.250.0020.00516.88
8.0.240.0050.00316.87
8.0.230.0030.00316.96
8.0.220.0000.00716.79
8.0.210.0030.00316.86
8.0.200.0030.00316.90
8.0.190.0050.00316.93
8.0.180.0040.00416.95
8.0.170.0000.00916.92
8.0.160.0080.00016.80
8.0.150.0150.00816.80
8.0.140.0150.00516.72
8.0.130.0190.00316.88
8.0.120.0120.00816.74
8.0.110.0180.00416.78
8.0.100.0150.00816.85
8.0.90.0170.00616.88
8.0.80.0080.01616.73
8.0.70.0110.01116.86
8.0.60.0110.00816.80
8.0.50.0180.00716.70
8.0.30.0110.01116.84
8.0.20.0190.00316.91
8.0.10.0180.00617.00
7.4.330.0050.00015.55
7.4.320.0060.00016.50
7.4.300.0000.00616.63
7.4.290.0030.00316.38
7.4.280.0030.00516.61
7.4.270.0160.01016.59
7.4.260.0220.00016.50
7.4.250.0180.00516.58
7.4.240.0230.00016.53
7.4.230.0190.00516.54
7.4.220.0170.00616.56
7.4.210.0200.00016.50
7.4.200.0150.00516.56
7.4.190.0230.00016.60
7.4.180.0110.01116.62
7.4.160.0160.00516.39
7.4.150.0190.00316.44
7.4.140.0140.00916.36
7.4.130.0190.00316.35
7.4.120.0140.00916.50
7.4.110.0150.00516.46
7.4.100.0180.00416.36
7.4.90.0170.00716.44
7.4.80.0180.00416.58
7.4.70.0150.00616.28
7.4.60.0150.00616.54
7.4.50.0170.00316.49
7.4.40.0130.00916.23
7.4.30.0150.00716.31
7.4.20.0130.00816.27
7.4.10.0170.00416.52
7.4.00.0230.00016.36

preferences:
15.92 ms | 403 KiB | 5 Q