I've been using this script in the past and was ok. I converted txt file to csv and have got some undefinded error.
function Importcsv($filename) { $row = 0;
$col = 0;
$handle = @fopen($filename, "r");
if ($handle)
{
while (($row = fgetcsv($handle, 4096)) !== false)
{
if (empty($fields))
{
$fields = $row;
continue;
}
foreach ($row as $k=>$value)
{
$results[$col][$fields[$k]] = $value;
}
$col++;
unset($row);
}
if (!feof($handle))
{
echo "Error: unexpected fgets() failn";
}
fclose($handle);
}
return $results; }
$filename = "tm_data.csv";
$csvArray = Importcsv($filename);
foreach ($csvArray as $row)
{
echo $row['CITY'];
}
Please let me know if you have any idea or discovered similar issues before.
Please see few error lines Notice: Undefined offset: 386 in /Applications/XAMPP/xamppfiles/htdocs/tm_marketing/index.php on line 20
Notice: Undefined offset: 387 in /Applications/XAMPP/xamppfiles/htdocs/tm_marketing/index.php on line 20
Notice: Undefined offset: 388 in /Applications/XAMPP/xamppfiles/htdocs/tm_marketing/index.php on line 20
Notice: Undefined offset: 389 in /Applications/XAMPP/xamppfiles/htdocs/tm_marketing/index.php on line 20
Notice: Undefined offset: 390 in /Applications/XAMPP/xamppfiles/htdocs/tm_marketing/index.php on line 20
Thanks,