-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
Description
I'm reading CSV files using SplFileObject class and fgetcsv method. Below code does not work as intended in HHVM 3.8.0 meaning fgetcsv does return false on the LAST line. In PHP 5.6.7-1 the last line returns null.
With the following CSV file
row11;;row13
row21;row22;row23
and the following code
$aFile = new SplFileObject ($aPath);
$aFile->setFlags(SplFileObject::SKIP_EMPTY | SplFileObject::READ_AHEAD | SplFileObject::DROP_NEW_LINE | SplFileObject::READ_CSV);
$aFile->setCsvControl(';');
for($i = 0; $i < 3; $i++) {
$row = $aFile->fgetcsv();
var_dump($row);
}Result for PHP
array(3) {
[0] =>
string(5) "row11"
[1] =>
string(0) ""
[2] =>
string(5) "row13"
}
array(3) {
[0] =>
string(5) "row21"
[1] =>
string(5) "row22"
[2] =>
string(5) "row23"
}
NULL
Result for HHVM
array(3) {
[0]=>
string(5) "row11"
[1]=>
string(0) ""
[2]=>
string(5) "row13"
}
array(3) {
[0]=>
string(5) "row21"
[1]=>
string(5) "row22"
[2]=>
string(5) "row23"
}
bool(false)
Reactions are currently unavailable