if (($handle = fopen($tmpname, 'r')) !== FALSE) {
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
$isempty = true;
array_walk($data, function(&$a)use (&$isempty){
$a = trim($a);
if($a != ''){
$t = mb_detect_encoding($a,["UTF-8","GB2312","GBK","BIG5"]);
if($t !== false && $t != "UTF-8"){
$a = mb_convert_encoding($a, 'UTF-8', $t);
}
$isempty = false;
}
});
if( $isempty ) continue;
//......
}
fclose($handle);
}
php 导入csv文件
最新推荐文章于 2023-09-24 09:00:00 发布