[edit]Nevermind, I got the solution. I am using trim() for each line, which removes all whitespaces
\r etc. Removing them from the code below returns the result that i want…[/edit]
Sorry for the late reply.
Yes you are right, but when I change the code of the __construct function in the csv.php file to the following
public function __construct($file)
{
$this->filePath = $file;
// Read the file contents and store it into a private variable
$fp = fopen ($file, "r");
$j = 0;
while(!feof($fp)){
if ($j == 0) {
$line = trim( fgets($fp, 4096) );
} else {
$line = fgets($fp, 4096);
if(mb_detect_encoding($line, 'UTF-8', true)) {
$line = trim( $line );
} else {
$line = trim( utf8_encode($line ) );
}
}
if (strlen($line) != 0) {
$fileContents[] = $line;
}
$j++;
}
$this->fileContents = $fileContents;
}
It cannot get the delimiter. I understand that fgets() ignores the \r,
, or \f indicators, so is there any way to make it detect those indicators in the above code example?
Thanks