3v4l.org

run code in 300+ PHP versions simultaneously
<?php function csv_reverse($handle, ...$csv_options) { $offsets = []; do { $offsets[] = ftell($handle); } while($row = fgetcsv($handle, ...$csv_options)); array_pop($offsets); // last offset is EOF for( $i=count($offsets)-1; $i>=0; --$i ) { fseek($handle, $offsets[$i]); yield fgetcsv($handle, ...$csv_options); } } $csv = <<<_E_ id,name,value 1,foo,"hello world" 2,bar,"hello world" 3, baz,"""hello world""" _E_; $in = fopen('php://memory', 'rwb'); fwrite($in, $csv); rewind($in); fgets($in); foreach( csv_reverse($in, null, ',', '"', '\\') as $row ) { var_dump($row); }

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.4.130.0110.00919.53
8.4.120.0070.00520.73
8.4.110.0050.00518.96
8.4.100.0120.00918.43
8.4.90.0100.01020.61
8.4.80.0150.00520.32
8.4.70.0100.01017.70
8.4.60.0070.00218.70
8.4.50.0120.00818.48
8.4.40.0070.00317.58
8.4.30.0120.00322.34
8.4.20.0120.00822.25
8.4.10.0090.00923.99
8.3.260.0140.00616.51
8.3.250.0140.00517.17
8.3.240.0120.00616.54
8.3.230.0110.00516.86
8.3.220.0040.00419.07
8.3.210.0090.00916.72
8.3.200.0060.00216.68
8.3.190.0120.00717.13
8.3.180.0050.00718.36
8.3.170.0050.00317.35
8.3.160.0070.00818.34
8.3.150.0140.00420.95
8.3.140.0030.00718.52
8.3.130.0080.00016.62
8.3.120.0100.01018.77
8.3.110.0040.00420.94
8.3.100.0000.00824.06
8.3.90.0000.00826.77
8.3.80.0030.00918.42
8.3.70.0070.01416.63
8.3.60.0030.01220.32
8.3.50.0120.00316.80
8.3.40.0110.00721.73
8.3.30.0030.01020.33
8.3.20.0070.00024.18
8.3.10.0040.00424.66
8.3.00.0040.00426.16
8.2.290.0070.01020.35
8.2.280.0070.00418.42
8.2.270.0060.01217.07
8.2.260.0060.00320.02
8.2.250.0060.00317.01
8.2.240.0060.00317.27
8.2.230.0030.00522.58
8.2.220.0070.00337.54
8.2.210.0000.01426.77
8.2.200.0100.00018.67
8.2.190.0040.01116.63
8.2.180.0070.00716.48
8.2.170.0110.00422.96
8.2.160.0040.01122.96
8.2.150.0030.00625.66
8.2.140.0080.00024.66
8.2.130.0050.00326.16
8.2.120.0000.00822.25
8.2.110.0110.01122.25
8.2.100.0120.00018.03
8.2.90.0080.00018.16
8.2.80.0060.00317.97
8.2.70.0070.00417.97
8.2.60.0190.00017.97
8.2.50.0150.00417.97
8.2.40.0070.01017.97
8.2.30.0170.00017.97
8.2.20.0140.00317.97
8.2.10.0100.00817.97
8.2.00.0090.00617.97
8.1.330.0090.00922.14
8.1.320.0110.00816.41
8.1.310.0040.00416.79
8.1.300.0060.01218.26
8.1.290.0050.00530.84
8.1.280.0140.00725.92
8.1.270.0080.00024.66
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0000.01121.88
8.1.230.0080.00320.89
8.1.220.0070.00317.77
8.1.210.0200.00017.97
8.1.200.0130.00617.97
8.1.190.0130.00517.97
8.1.180.0090.00917.97
8.1.170.0130.00317.97
8.1.160.0160.00217.97
8.1.150.0140.00317.97
8.1.140.0060.01217.97
8.1.130.0160.00417.97
8.1.120.0090.00617.97
8.1.110.0100.00717.97
8.1.100.0170.00017.97
8.1.90.0130.00617.97
8.1.80.0100.00717.97
8.1.70.0120.00417.97
8.1.60.0090.00917.97
8.1.50.0100.00717.97
8.1.40.0170.00317.97
8.1.30.0150.00417.97
8.1.20.0140.00617.97
8.1.10.0120.00517.97
8.1.00.0170.00317.97
8.0.300.0000.00820.10
8.0.290.0070.01117.97
8.0.280.0090.00917.97
8.0.270.0170.00017.97
8.0.260.0040.01317.97
8.0.250.0140.00317.97
8.0.240.0130.00317.97
8.0.230.0100.00717.97
8.0.220.0170.00017.97
8.0.210.0130.00417.97
8.0.200.0130.00517.97
8.0.190.0070.01117.97
8.0.180.0110.00817.97
8.0.170.0150.00017.97
8.0.160.0160.00417.97
8.0.150.0120.00617.97
8.0.140.0120.00317.97
8.0.130.0140.00317.97
8.0.120.0130.00317.97
8.0.110.0140.00317.97
8.0.100.0180.00017.97
8.0.90.0170.00017.97
8.0.80.0110.00517.97
8.0.70.0100.00717.97
8.0.60.0120.00417.97
8.0.50.0110.00817.97
8.0.30.0110.00417.97
8.0.20.0070.01017.97
8.0.10.0170.00017.97

preferences:
27.07 ms | 403 KiB | 5 Q