Is it possible to detect in the following code example if the current row is the last row? Here is my code:
$file = \fopen('/path/to/file.csv', 'rb');
while (($row = \fgetcsv($file, 0, ';')) !== false) {
// Detect if it is the last row
$isLastRow = ?;
// Do some stuff for all rows and pass if it is the last row
$myService->handleRow($row, $isLastRow);
}
I already tried it with $isLastRow = feof($file);, but that was not working. Does anyone have any ideas on how to do this?
I think I have found a solution after all, contrary to the comments. This seems to work: