久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      如何解決php讀取excel亂碼問題

      php讀取excel亂碼問題的解決辦法:1、修改“excel_class.php”類文件為“$s=iconv(‘utf-16le’,'utf-8′,$exc->sst['data'][$ind])”;2、注釋掉“uc2html”函數(shù)。

      如何解決php讀取excel亂碼問題

      推薦:《PHP視頻教程》

      php讀取excel中文亂碼 excel_class…

      今天碰到了大問題,就是讀取excel的中文亂碼大問題!

      Excel_class.php是一款php導(dǎo)入excel的工具,它可以方便從excel導(dǎo)入數(shù)據(jù)到php,也可以方便用php把數(shù)據(jù)導(dǎo)入到excel.但是今天很不給力!

      我搜集了很多資料就是沒找到,后來想到:百度使我們最好的老師。好了,現(xiàn)在就找老師去!

      果然,在百度上搜到了關(guān)于這個(gè)工具的處理亂碼的方法。

      第一種方法:修改excel_class.php類文件,查找$s = uc2html($exc->sst['data'][$ind]);替換 為 $s = iconv(‘utf-16le’,'utf-8′,$exc->sst['data'][$ind]),這樣編碼就是utf-8了.

      如果還想把數(shù)據(jù)再導(dǎo)入mysql,而你的mysql編碼是GB2312,那么你就需要再把數(shù)據(jù)從utf-8轉(zhuǎn)到gb2312了,可以這樣:$s=iconv(“UTF-8″,”GB2312″,$s)。

      第二種方法:打開excel_class.php,找到函數(shù)uc2html, 將函數(shù)中的代碼注釋掉,直接將參數(shù)返回,即改函數(shù)不做任何操作。

      function uc2html($str) { return $str; }

      接下來使用PHP中提供的函數(shù)mb_convert_encoding來將UTF-16LE轉(zhuǎn)換成UTF-8。

      echo mb_convert_encoding($return[Sheet2][0][0], ‘UTF-8′, ‘UTF-16LE’);

      這樣顯示就正常了。

      總結(jié):在我的測(cè)試過程中,建議用第一種方法,第二種方法把數(shù)字變成亂碼了(不知道什么原因)。

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)