php 导入csv文件

来源:互联网 发布:linux怎么安装字体 编辑:程序博客网 时间:2024/05/22 12:48
            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);        }

0 0