3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php error_reporting(-1); $tmp = tempnam('/tmp', 'php'); $fp = fopen($tmp, 'w+'); fwrite($fp, 'foo,bar,baz,bat'); rewind($fp); $line = fgetcsv($fp); var_dump($line); rewind($fp); $line = fgetcsv($fp, 0); var_dump($line); rewind($fp); $line = fgetcsv($fp, 10); var_dump($line);
Output for 5.1.0 - 7.1.0
array(4) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(3) "baz" [3]=> string(3) "bat" } array(4) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(3) "baz" [3]=> string(3) "bat" } array(3) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(2) "ba" }
Output for 5.0.4 - 5.0.5
array(4) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(3) "baz" [3]=> string(3) "bat" } array(1) { [0]=> string(1) "f" } array(3) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(2) "ba" }
Output for 5.0.0 - 5.0.3
array(4) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(3) "baz" [3]=> string(3) "bat" } bool(false) array(3) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(2) "ba" }
Output for 4.3.0 - 4.4.9
Warning: Wrong parameter count for fgetcsv() in /in/EuZhj on line 8 NULL bool(false) array(3) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(1) "b" }