I have one CSV file with two fields field1
and field2
. When I try to loop throught each row of my CSV file it only return first row of file.
Notice, that file is uploaded and valid.
Here is my code:
/**
* Get File Contents
*/
$csv = Reader::createFromPath(storage_path('folder/'.$FILE_NAME));
$csv->setOffset(1);
/**
* CSV Properties
*/
$delimiter = $csv->getDelimiter();
$enclosure = $csv->getEnclosure();
/**
* Processing CSV File
*/
$temp_data = "";
$csv->each(function($row) use ($position1, $position2, $delimiter, &$temp_data, $enclosure)
{
$temp_data .= $enclosure.$row[$position1].$enclosure.$delimiter.
$enclosure.$row[$position2].$enclosure."/n";
echo $temp_data;
});
exit;
Does anyone have an idea why I'm getting only the first row of the file?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Y6XbKl
via IFTTT
Aucun commentaire:
Enregistrer un commentaire