Created
March 19, 2019 17:10
-
-
Save mig1098/a1898ceec4ee843f87571be11d82f9fe to your computer and use it in GitHub Desktop.
Read csv files from csv. PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//tmp_name from input file | |
//@param array $tmp | |
//@return array | |
function leercsv($tmp){ | |
$arrayData = array(); | |
if(!($handle = @fopen ($tmp, 'rb'))){ | |
throw new \Exception('Error en la carga del fichero'); | |
}else{ | |
$row = 1; | |
while (($data = fgetcsv($handle, 10000, $sp, '"')) != FALSE){ | |
if($row == 1){ $row++; continue; } | |
if($data[0]!= '' && $data[1] != ''){ | |
$arrayData[] = $data; | |
} | |
} | |
} | |
return $arrayData; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment