3v4l.org

run code in 300+ PHP versions simultaneously
<?php function checkIfJobAlreadyExistsAndUpdateCsv(array $csvRows) { $thisJob = false; $existingJobsAndItsDetails = []; $items = []; foreach ($csvRows as $index => $row) { echo PHP_EOL . 'This is row 0 value: '. $row[0]; if ($row[0] === 'H') { $thisJob = false; echo PHP_EOL . 'This job number: ' . $thisJob; if ($row[1] == 'BB2') { $thisJob = $row[1]; $existingJobsAndItsDetails[$thisJob]= $thisJob; unset($csvRows[$index]); } } if ($row[0] === 'D' && $thisJob) { echo PHP_EOL . 'This item number: ' . $row[1]; $items[$thisJob][] = $row; unset($csvRows[$index]); } } echo PHP_EOL . 'Final Array: '; foreach ($existingJobsAndItsDetails as $jobId => $thisJob) { echo PHP_EOL . 'This job number: ' . $thisJob; if (isset($items[$thisJob])) { foreach ($items[$thisJob] as $itemRow) { $productCode = $itemRow[1]; echo PHP_EOL . $productCode; } } } return $existingJobsAndItsDetails; } $myArray = [['H','AA1 ','598.12'], ['D','itemA1','PRAWN: KING - BAP - RAW PEELED DEVEINED 16-20 (700GM NETT PACK)'], ['D','itemA2','HADDOCK: FILLET 220-280GM SKINNED (KG)'], ['D','itemA3','SEABASS: WILD - WHOLE 2-3KG (KG)'], ['D','itemA4','MACKEREL: FILLETED LARGE (KG)'], ['H','BB2','68.93'], ['D','itemB1','TUNA : SASHIMI GRADE - LOIN ( KG )'], ['H','CC3','8.5']]; echo print_r(checkIfJobAlreadyExistsAndUpdateCsv($myArray), 1);

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.60.0130.00318.55
8.3.50.0070.01116.64
8.3.40.0110.00418.79
8.3.30.0000.01518.83
8.3.20.0000.00819.23
8.3.10.0000.00823.52
8.3.00.0050.00323.55
8.2.180.0100.00718.16
8.2.170.0070.01022.96
8.2.160.0070.00718.96
8.2.150.0050.00324.18
8.2.140.0000.00724.66
8.2.130.0000.00826.16
8.2.120.0060.00619.78
8.2.110.0070.00320.51
8.2.100.0060.00617.91
8.2.90.0030.00517.63
8.2.80.0040.00418.91
8.2.70.0060.00317.75
8.2.60.0040.00417.93
8.2.50.0050.00318.07
8.2.40.0000.00818.29
8.2.30.0040.00418.13
8.2.20.0040.00418.00
8.2.10.0040.00419.56
8.2.00.0020.00519.40
8.1.280.0100.00725.92
8.1.270.0020.00522.10
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0100.00018.90
8.1.230.0120.00017.68
8.1.220.0000.00817.79
8.1.210.0030.00518.77
8.1.200.0060.00317.47
8.1.190.0090.00017.38
8.1.180.0000.00818.10
8.1.170.0040.00418.68
8.1.160.0030.00518.95
8.1.150.0040.00418.75
8.1.140.0040.00419.48
8.1.130.0030.00319.01
8.1.120.0000.00717.36
8.1.110.0070.00017.49
8.1.100.0000.00717.49
8.1.90.0060.00317.45
8.1.80.0030.00617.38
8.1.70.0030.00317.48
8.1.60.0060.00317.50
8.1.50.0030.00617.40
8.1.40.0080.00017.44
8.1.30.0000.01017.67
8.1.20.0000.00717.59
8.1.10.0040.00417.55
8.1.00.0040.00417.50
8.0.300.0060.00318.77
8.0.290.0000.00916.75
8.0.280.0040.00418.41
8.0.270.0070.00016.81
8.0.260.0060.00017.13
8.0.250.0030.00316.95
8.0.240.0030.00316.84
8.0.230.0030.00516.83
8.0.220.0030.00316.88
8.0.210.0030.00316.89
8.0.200.0060.00316.81
8.0.190.0000.00716.91
8.0.180.0080.00016.81
8.0.170.0060.00316.82
8.0.160.0070.00016.91
8.0.150.0080.00016.73
8.0.140.0050.00216.87
8.0.130.0000.00513.34
8.0.120.0000.00816.84
8.0.110.0080.00016.80
8.0.100.0000.00816.93
8.0.90.0030.00316.77
8.0.80.0050.01416.92
8.0.70.0000.00816.95
8.0.60.0070.00016.72
8.0.50.0040.00416.84
8.0.30.0120.00617.10
8.0.20.0130.00617.40
8.0.10.0000.00717.13
8.0.00.0080.01216.70
7.4.330.0020.00215.55
7.4.320.0060.00316.53
7.4.300.0000.00616.45
7.4.290.0090.00316.63
7.4.280.0040.00416.59
7.4.270.0040.00416.53
7.4.260.0000.00716.59
7.4.250.0040.00316.57
7.4.240.0000.00716.45
7.4.230.0030.00316.50
7.4.220.0000.00816.59
7.4.210.0090.00916.59
7.4.200.0040.00416.40
7.4.160.0100.00816.46
7.4.140.0090.01017.86
7.4.130.0120.00616.58
7.4.120.0110.00716.57
7.4.110.0030.01416.56
7.4.100.0150.00916.69
7.4.90.0120.00616.48
7.4.80.0040.01319.39
7.4.70.0060.00916.59
7.4.60.0090.00716.43
7.4.50.0130.00016.44
7.4.40.0100.01316.45
7.4.10.0070.01014.96
7.4.00.0090.00914.91
7.3.330.0030.00313.15
7.3.320.0000.00713.23
7.3.310.0040.00416.50
7.3.300.0060.00016.38
7.3.290.0000.00616.38
7.3.280.0060.01316.38
7.3.260.0100.01016.47
7.3.240.0100.01016.48
7.3.230.0050.01316.39
7.3.210.0200.00016.68
7.3.200.0030.01216.59
7.3.190.0140.01016.41
7.3.180.0090.00716.61
7.3.170.0180.00016.59
7.3.160.0140.00716.50
7.3.130.0030.01415.03
7.3.120.0080.00815.01
7.3.110.0090.00914.89
7.3.100.0040.00814.79
7.3.90.0020.01114.69
7.3.80.0070.00714.88
7.3.70.0050.01014.96
7.3.60.0050.00714.99
7.3.50.0050.01015.03
7.3.40.0050.00814.63
7.3.30.0110.00114.73
7.3.20.0060.00916.78
7.3.10.0040.00916.69
7.3.00.0060.00716.76
7.2.330.0110.00716.51
7.2.320.0070.00916.75
7.2.310.0080.00816.83
7.2.300.0110.01416.55
7.2.290.0090.01316.58
7.2.260.0030.01615.38
7.2.250.0070.00914.97
7.2.240.0100.00515.23
7.2.230.0060.01015.21
7.2.220.0060.00915.19
7.2.210.0130.00315.08
7.2.200.0030.00615.01
7.2.190.0040.00715.18
7.2.180.0100.00515.02
7.2.170.0080.00515.15
7.2.160.0120.00314.94
7.2.150.0120.00316.71
7.2.140.0150.00016.93
7.2.130.0070.00716.96
7.2.120.0060.00616.73
7.2.110.0050.00816.84
7.2.100.0100.00317.08
7.2.90.0060.00616.86
7.2.80.0190.00515.93
7.2.70.0110.00815.90
7.2.60.0130.00716.17
7.2.50.0140.00516.01
7.2.40.1220.00916.00
7.2.30.0130.01016.16
7.2.20.0170.01016.04
7.2.10.0120.01016.06
7.2.00.0130.01015.96
7.1.330.0060.00615.98
7.1.320.0060.00715.90
7.1.310.0020.01015.75
7.1.300.0050.00715.80
7.1.290.0080.00315.85
7.1.280.0040.00815.74
7.1.270.0060.00915.94
7.1.260.0080.00715.73
7.1.250.0090.00315.99
7.1.240.0030.01015.89
7.1.230.0030.00715.54
7.1.220.0040.00815.72
7.1.210.0040.01115.79
7.1.200.0070.00715.76
7.1.190.0160.00514.90
7.1.180.0120.00814.71
7.1.170.0130.00914.93
7.1.160.0120.00614.78
7.1.150.0250.00314.79
7.1.140.0150.01115.03
7.1.130.0120.00714.81
7.1.120.0110.00714.89
7.1.110.0130.00714.97
7.1.100.0130.00714.80
7.1.90.0120.00614.81
7.1.80.0150.00514.85
7.1.70.0110.00914.88
7.1.60.0190.00623.69
7.1.50.0180.01123.77
7.1.40.0230.00323.84
7.1.30.0190.00623.90
7.1.20.0160.01223.66
7.1.10.0130.00614.75
7.1.00.0140.00714.88
7.0.330.0000.01115.65
7.0.320.0040.00815.19
7.0.310.0040.00415.36
7.0.300.0100.00315.59
7.0.290.0040.00715.54
7.0.280.0060.00615.37
7.0.270.0030.00715.58
7.0.260.0100.00315.17
7.0.250.0030.01015.54
7.0.240.0100.00615.40
7.0.230.0030.00815.45
7.0.220.0070.00715.18
7.0.210.0100.00315.50
7.0.200.0070.00315.23
7.0.190.0070.00715.52
7.0.180.0110.00615.65
7.0.170.0000.01315.62
7.0.160.0070.00715.53
7.0.150.0040.01115.46
7.0.140.0030.00615.26
7.0.130.0000.01315.60
7.0.120.0060.00315.37
7.0.110.0040.00715.38
7.0.100.0030.01315.56
7.0.90.0130.00315.43
7.0.80.0000.01615.39
7.0.70.0030.01015.39
7.0.60.0090.00015.51
7.0.50.0030.01015.66
7.0.40.0070.00713.58
7.0.30.0000.01713.46
7.0.20.0040.00813.54
7.0.10.0100.00313.52
7.0.00.0040.01113.58
5.6.400.0030.01214.45
5.6.390.0060.00614.81
5.6.380.0100.00314.49
5.6.370.0100.00014.67
5.6.360.0030.01214.75
5.6.350.0040.00714.72
5.6.340.0120.00314.13
5.6.330.0080.00414.60
5.6.320.0070.00714.73
5.6.310.0120.00014.34
5.6.300.0100.00714.88
5.6.290.0110.00014.55
5.6.280.0000.01114.55
5.6.270.0060.00314.50
5.6.260.0110.00314.50
5.6.250.0030.01214.57
5.6.240.0060.01214.44
5.6.230.0030.01014.57
5.6.220.0130.00314.44
5.6.210.0070.00714.43
5.6.200.0030.01014.70
5.6.190.0000.01614.54
5.6.180.0060.00614.68
5.6.170.0000.01714.37
5.6.160.0030.01014.75
5.6.150.0000.01614.75
5.6.140.0070.01014.33
5.6.130.0000.01514.27
5.6.120.0000.01114.55
5.6.110.0000.01414.43
5.6.100.0090.00614.66
5.6.90.0030.00814.34
5.6.80.0070.00414.14
5.6.70.0000.01214.36
5.6.60.0000.01214.71
5.6.50.0060.00314.16
5.6.40.0000.00914.29
5.6.30.0030.01014.30
5.6.20.0060.00614.43
5.6.10.0070.00414.27
5.6.00.0040.01114.45

preferences:
49.06 ms | 400 KiB | 5 Q