3v4l.org

run code in 300+ PHP versions simultaneously
<?php $crlf = chr(13) . chr(10); $cr = chr(13); $delimiter = '|'; $enclosure = '"'; //$escape = "\\"; $escape = "\0"; ini_set('auto_detect_line_endings', false); // 7 rows, 5th row has CR linebreak inside $lines = [ 'A', 'a', 'C15|C18|C21|C36|C42|C45|C48|C51|C54|C60|C63|C66|C69|C72|C75|C81|C84|C90|C93|C96|C99|C102|C105|C108|C111', '02-DEC-19|02-DEC-19|707403|GUEST|||PPPPPP||||||RR||||RRSSIAN||FFFF|||||+1111-11-11-111|', '02-DEC-19|02-DEC-19|707404|GUEST|SDDDDD|ВВВВВВВВВВВВ|PPPPPP|СССССС|ПППППП||01.01.1111|M|RR|ППППП|"ПППППППП кккк' . $cr . '"|MISSING LINE CONTENTS|', 'FF_FFFF|FF_1', '|1', ]; $csv = implode($crlf, $lines); $filePath = tempnam(sys_get_temp_dir(), 'csv'); file_put_contents($filePath, $csv); $file = new \SplFileObject($filePath, 'r'); $file->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV); $rows = []; while (!$file->eof()) { $row = $file->fgetcsv($delimiter, $enclosure, $escape); if ($row === null) { print_r("NULL result found though `SplFileObject::SKIP_EMPTY | SplFileObject::DROP_NEW_LINE` flags set.\n"); } else { $rows[] = implode($delimiter, $row); } } if (str_replace($enclosure, '', implode($crlf, $lines)) !== implode($crlf, $rows)) { print_r("SplFileObject::fgetcsv() error! Expected:\n"); print_r($lines); print_r("Parsed as:\n"); print_r($rows); } else { print_r("SplFileObject::fgetcsv() passed."); } unset($file); // via fopen print_r("\n\n\n"); $file = fopen($filePath, 'r'); $rows = []; while (!feof($file)) { $row = fgetcsv($file, 0, $delimiter, $enclosure, $escape); if ($row === null) { print_r("NULL result found\n"); } else { $rows[] = implode($delimiter, $row); } } if (str_replace($enclosure, '', implode($crlf, $lines)) !== implode($crlf, $rows)) { print_r("fgetcsv() error! Expected:\n"); print_r($lines); print_r("Parsed as:\n"); print_r($rows); } else { print_r("fgetcsv() passed."); }

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.1.90.0040.00417.39
8.1.80.0070.00017.56
8.1.70.0030.00317.44
8.1.60.0050.00517.51
8.1.50.0040.00417.60
8.1.40.0030.00617.54
8.1.30.0030.00517.63
8.1.20.0040.00417.70
8.1.10.0030.00617.60
8.1.00.0000.00917.57
8.0.220.0030.00316.96
8.0.210.0050.00216.93
8.0.200.0030.00316.97
8.0.190.0030.00517.11
8.0.180.0030.00616.92
8.0.170.0030.00616.98
8.0.160.0000.00717.03
8.0.150.0000.00816.97
8.0.140.0050.00316.88
8.0.130.0060.00013.49
8.0.120.0050.00316.93
8.0.110.0000.00817.04
8.0.100.0000.00817.05
8.0.90.0000.00917.00
8.0.80.0000.01616.90
8.0.70.0050.00316.96
8.0.60.0030.00517.08
8.0.50.0040.00417.04
8.0.30.0230.00316.98
8.0.20.0120.00917.41
8.0.10.0050.00317.14
8.0.00.0090.00916.86
7.4.300.0000.00616.57
7.4.290.0050.00216.47
7.4.280.0000.01016.55
7.4.270.0050.00316.57
7.4.260.0030.00313.28
7.4.250.0040.00416.63
7.4.240.0020.00616.61
7.4.230.0080.00016.30
7.4.220.0030.00416.54
7.4.210.0090.00816.64
7.4.200.0040.00416.37
7.4.130.0090.00916.56
7.4.120.0140.01116.64
7.4.110.0130.01216.65
7.4.100.0100.01416.50
7.4.90.0130.00316.65
7.4.80.0150.00419.39
7.4.70.0060.01216.82
7.4.60.0090.00616.51
7.4.50.0070.01116.59
7.4.40.0090.00916.69
7.4.00.0100.00714.89
7.3.330.0080.00216.58
7.3.320.0030.00313.41
7.3.310.0050.00316.52
7.3.300.0040.00216.27
7.3.290.0000.00716.46
7.3.280.0090.01216.44
7.3.260.0290.01816.56
7.3.240.0070.01316.42
7.3.230.0130.00616.32
7.3.210.0080.01216.59
7.3.200.0080.00816.56
7.3.190.0110.00816.46
7.3.180.0060.01216.52
7.3.170.0150.00616.77
7.3.160.0150.00316.71
7.3.120.0050.01014.80
7.3.110.0060.01114.83
7.3.100.0120.00914.87
7.3.90.0040.01114.90
7.3.80.0030.01214.81
7.3.70.0080.00814.75
7.3.60.0070.00814.75
7.3.50.0090.00514.86
7.3.40.0110.00814.77
7.3.30.0040.01014.72
7.3.20.0150.01115.57
7.3.10.0080.00615.84
7.3.00.0070.00815.56
7.2.330.0120.00616.81
7.2.320.0090.00916.86
7.2.310.0110.00616.90
7.2.300.0160.00316.75
7.2.290.0090.00916.90
7.2.250.0090.00615.12
7.2.240.0040.01115.26
7.2.230.0070.01015.04
7.2.220.0110.00515.08
7.2.210.0100.00515.00
7.2.200.0090.00815.11
7.2.190.0060.01014.89
7.2.180.0080.01015.02
7.2.170.0040.01014.89
7.1.330.0100.00314.08
7.1.320.0040.01114.04
7.1.310.0110.00313.96
7.1.300.0040.01013.88
7.1.290.0090.00713.95
7.1.280.0080.00614.03
7.1.270.0040.01013.99
7.1.260.0120.01014.73

preferences:
10.78 ms | 406 KiB | 5 Q