3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Simulated file data $data = <<<TAG Hunky Bill's Big Perogie / Pierogi Maker 9 4 10 5 5 1 2 1 TAG; // This allows us to create a stream pointing to a string. // This is only done to match the OP's code $csv_file = 'data://text/plain,'.$data; // We'll store items here temporarily $csv_items = []; if (($fp = fopen($csv_file, 'r'))) { while (!feof($fp)) { $item = fgets($fp); // Sanity check that we received something if (false === $item) { break; } // Trim both sides (unless you have a need for whitespace) $item = trim($item); // If we still have more than just an empty string if ($item) { // Append, optionally with quotes $csv_items[] = '"'.$item.'"'; } } fclose($fp); } // Create final string $csv_string = implode(',', $csv_items); var_dump($csv_string);

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.80.0110.00816.80
8.5.70.0100.00718.52
8.5.60.0090.00916.82
8.5.50.0120.00616.48
8.5.30.0060.01118.81
8.5.20.0110.00819.41
8.5.10.0090.00816.59
8.5.00.0130.00720.06
8.4.230.0050.00419.39
8.4.220.0110.00919.54
8.4.210.0100.01021.41
8.4.180.0140.00719.55
8.4.170.0150.00820.55
8.4.160.0120.01020.73
8.4.150.0030.00316.88
8.4.140.0160.00517.34
8.4.130.0090.01118.70
8.4.120.0040.00522.35
8.4.110.0050.00418.92
8.4.100.0130.00717.85
8.4.90.0090.01220.50
8.4.80.0090.00924.04
8.4.70.0130.00719.00
8.4.60.0120.00920.45
8.4.50.0110.00820.61
8.4.40.0030.01317.71
8.4.30.0160.00320.31
8.4.20.0100.01017.88
8.4.10.0060.00319.51
8.3.320.0070.00618.60
8.3.310.0130.00718.52
8.3.300.0110.00819.31
8.3.290.0080.01320.96
8.3.280.0130.00818.61
8.3.270.0120.00916.36
8.3.260.0130.00616.69
8.3.250.0140.00617.16
8.3.240.0120.00816.43
8.3.230.0150.00616.48
8.3.220.0110.00719.10
8.3.210.0160.00416.95
8.3.200.0110.00916.47
8.3.190.0120.00417.11
8.3.180.0130.00618.83
8.3.170.0080.01117.48
8.3.160.0100.01016.67
8.3.150.0120.00617.29
8.3.140.0040.01116.90
8.3.130.0100.01016.61
8.3.120.0090.00918.73
8.3.110.0090.00020.94
8.3.100.0100.00716.64
8.3.90.0030.00626.77
8.3.80.0060.00316.63
8.3.70.0070.00716.63
8.3.60.0090.00918.43
8.3.50.0040.01119.77
8.3.40.0080.00818.97
8.3.30.0070.00718.57
8.3.20.0070.00024.18
8.3.10.0050.00324.66
8.3.00.0070.00726.16
8.2.320.0110.00618.14
8.2.310.0120.00818.06
8.2.300.0120.00920.43
8.2.290.0090.01016.90
8.2.280.0080.01118.56
8.2.270.0030.00616.83
8.2.260.0140.00416.99
8.2.250.0040.00418.46
8.2.240.0050.00518.91
8.2.230.0000.00822.58
8.2.220.0030.00624.06
8.2.210.0000.00826.77
8.2.200.0060.00316.50
8.2.190.0120.00616.63
8.2.180.0130.00716.50
8.2.170.0120.00318.96
8.2.160.0130.00322.96
8.2.150.0060.00325.66
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0080.00021.00
8.2.110.0100.00720.44
8.2.100.0060.00617.91
8.2.90.0050.00318.03
8.2.80.0050.00517.97
8.2.70.0000.00817.63
8.2.60.0000.01017.80
8.2.50.0000.00817.79
8.2.40.0060.00319.77
8.2.30.0000.00817.85
8.2.20.0000.00720.64
8.2.10.0000.00817.65
8.2.00.0050.00219.41
8.1.340.0130.00620.30
8.1.330.0080.01018.00
8.1.320.0110.00916.02
8.1.310.0000.00816.41
8.1.300.0060.00316.18
8.1.290.0030.00630.84
8.1.280.0090.00925.92
8.1.270.0040.00422.17
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0040.00422.59
8.1.230.0060.00622.82
8.1.220.0040.00417.88
8.1.210.0090.00018.77
8.1.200.0040.00417.25
8.1.190.0040.00417.23
8.1.180.0030.00618.10
8.1.170.0040.00417.62
8.1.160.0040.00418.77
8.1.150.0000.00818.58
8.1.140.0050.00217.54
8.1.130.0030.00318.96
8.1.120.0040.00417.39
8.1.110.0070.00017.47
8.1.100.0000.00717.52
8.1.90.0020.00517.39
8.1.80.0030.00617.37
8.1.70.0030.00317.51
8.1.60.0040.00417.63
8.1.50.0080.00017.52
8.1.40.0040.00717.54
8.1.30.0060.00317.66
8.1.20.0000.00717.73
8.1.10.0040.00417.45
8.1.00.0040.00417.31
8.0.300.0000.00719.98
8.0.290.0050.00316.88
8.0.280.0000.00718.55
8.0.270.0050.00316.98
8.0.260.0030.00318.54
8.0.250.0000.00817.10
8.0.240.0000.00716.98
8.0.230.0070.00017.15
8.0.220.0070.00017.05
8.0.210.0000.00817.01
8.0.200.0030.00317.14
8.0.190.0030.00617.09
8.0.180.0000.00717.09
8.0.170.0080.00017.07
8.0.160.0030.00617.02
8.0.150.0000.00716.98
8.0.140.0040.00416.89
8.0.130.0140.00617.00
8.0.120.0110.01117.02
8.0.110.0110.01116.94
8.0.100.0100.01017.01
8.0.90.0200.00516.92
8.0.80.0240.00017.01
8.0.70.0200.00416.83
8.0.60.0130.00917.04
8.0.50.0170.00716.93
8.0.30.0160.00816.86
8.0.20.0160.00916.90
8.0.10.0140.01017.12
8.0.00.0080.00416.98
7.4.330.0000.00515.55
7.4.320.0030.00316.64
7.4.300.0060.00016.68
7.4.290.0000.00716.63
7.4.280.0030.00516.54
7.4.270.0040.00416.59
7.4.260.0290.00016.59
7.4.250.0240.00416.56
7.4.240.0250.00016.52
7.4.230.0100.01616.48
7.4.220.0190.00416.60
7.4.210.0230.00016.66
7.4.200.0130.00616.63
7.4.190.0230.00016.60
7.4.180.0140.00616.68
7.4.160.0220.00016.60
7.4.150.0170.00616.62
7.4.140.0100.01016.50
7.4.130.0200.00316.59
7.4.120.0210.00016.57
7.4.110.0220.00016.38
7.4.100.0120.00916.50
7.4.90.0180.00316.61
7.4.80.0140.00716.44
7.4.70.0200.00216.51
7.4.60.0180.00616.61
7.4.50.0120.01016.38
7.4.40.0130.00816.36
7.4.30.0140.00716.37
7.4.20.0130.00916.58
7.4.10.0120.00816.56
7.4.00.0210.00016.48
7.3.330.0250.00016.51
7.3.320.0200.00316.49
7.3.310.0150.00716.22
7.3.300.0170.00616.41
7.3.290.0180.00316.62
7.3.280.0260.00016.55
7.3.270.0180.00616.41
7.3.260.0210.00316.50
7.3.250.0240.00316.47
7.3.240.0190.00516.30
7.3.230.0200.00616.43
7.3.220.0280.00016.42
7.3.210.0170.00716.21
7.3.200.0150.00716.30
7.3.190.0200.00416.50
7.3.180.0190.00416.32
7.3.170.0200.00316.19
7.3.160.0220.00016.41
7.3.150.0200.00316.18
7.3.140.0230.00016.16
7.3.130.0140.00916.16

preferences:
46.34 ms | 1383 KiB | 5 Q