Exemplo n.º 1
0
 function prepareStr($str)
 {
     $str = trim(str_replace('"', '', $str));
     $str = iconv(get_string_encoding($str), "UTF-8", $str);
     //very very important
     $str = trim(str_replace('"', '', $str));
     $str = trim(str_replace('/([\\r\\n])+/', '', $str));
     $str = str_replace(array("\r\n", "\r", "\n"), " ", $str);
     //去除excel中的回车
     return $str;
 }
Exemplo n.º 2
0
function get_file_encoding($filename)
{
    $file_handle = fopen($filename, "r");
    $line = fgets($file_handle);
    fclose($file_handle);
    return get_string_encoding($line);
}