3v4l.org

run code in 300+ PHP versions simultaneously
<?php $csv = <<<'CSV' name, mail, age, bio john, j@ohn.com, 32, mary, mary@popp.com, 29, jeff, brid@ges.co, 47, "peterson, peter", peter@sson.com, 44, "loves: hobbies puzzles" CSV; $file = fopen('php://temp', 'rw'); var_dump($file); echo "\n"; fwrite($file, $csv); rewind($file); fpassthru($file); rewind($file); echo "\n\n"; function csv($file) { $header = null; while ($row = fgetcsv($file)) { $row = array_map('trim', $row); if ($header) { yield array_combine($header, $row); } else { $header = $row; } } } print_r(iterator_to_array(csv($file)));
Output for 8.4.1 - 8.4.2
resource(5) of type (stream) name, mail, age, bio john, j@ohn.com, 32, mary, mary@popp.com, 29, jeff, brid@ges.co, 47, "peterson, peter", peter@sson.com, 44, "loves: hobbies puzzles" Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/j65it on line 26 Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/j65it on line 26 Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/j65it on line 26 Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/j65it on line 26 Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/j65it on line 26 Deprecated: fgetcsv(): the $escape parameter must be provided as its default value will change in /in/j65it on line 26 Array ( [0] => Array ( [name] => john [mail] => j@ohn.com [age] => 32 [bio] => ) [1] => Array ( [name] => mary [mail] => mary@popp.com [age] => 29 [bio] => ) [2] => Array ( [name] => jeff [mail] => brid@ges.co [age] => 47 [bio] => ) [3] => Array ( [name] => peterson, peter [mail] => peter@sson.com [age] => 44 [bio] => loves: hobbies puzzles ) )
Output for 5.6.0 - 5.6.25, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.15
resource(5) of type (stream) name, mail, age, bio john, j@ohn.com, 32, mary, mary@popp.com, 29, jeff, brid@ges.co, 47, "peterson, peter", peter@sson.com, 44, "loves: hobbies puzzles" Array ( [0] => Array ( [name] => john [mail] => j@ohn.com [age] => 32 [bio] => ) [1] => Array ( [name] => mary [mail] => mary@popp.com [age] => 29 [bio] => ) [2] => Array ( [name] => jeff [mail] => brid@ges.co [age] => 47 [bio] => ) [3] => Array ( [name] => peterson, peter [mail] => peter@sson.com [age] => 44 [bio] => loves: hobbies puzzles ) )

preferences:
91.07 ms | 412 KiB | 5 Q