《php簡(jiǎn)單讀取.vcf格式文件的方法示例PHP實(shí)例:》要點(diǎn):
本文介紹了php簡(jiǎn)單讀取.vcf格式文件的方法示例PHP實(shí)例:,希望對(duì)您有用。如果有疑問(wèn),可以聯(lián)系我們。
PHP實(shí)例本文實(shí)例講述了php簡(jiǎn)單讀取.vcf格式文件的方法.分享給大家供大家參考,具體如下:
PHP實(shí)例 /** * 讀取.vcf格式文件 * @param $filename */ function readCvf($filename){ $file = fopen($filename,"r"); while(! feof($file)) { $line=fgets($file); $encoding = mb_detect_encoding($line, array('GB2312','GBK','UTF-16','UCS-2','UTF-8','BIG5','ASCII')); $content = iconv($encoding, "utf-8", $line); $arr = explode(":",$content) ; if($arr[0]=="NOTE;ENCODING=QUOTED-PRINTABLE"){ $temp= quoted_printable_decode($arr[1]); $encoding = mb_detect_encoding($temp, array('GB2312','GBK','UTF-16','UCS-2','UTF-8','BIG5','ASCII')); $arr[1] = iconv($encoding, "utf-8", $temp); } if(count($arr)==2){ $userInfo[$arr[0]] = $arr[1] ; } } fclose($file); return $userInfo; }
PHP實(shí)例經(jīng)常遇到亂碼問(wèn)題:解決方法兩步:
PHP實(shí)例 $encoding = mb_detect_encoding($line, array('GB2312','GBK','UTF-16','UCS-2','UTF-8','BIG5','ASCII')); $content = iconv($encoding, "utf-8", $line);
PHP實(shí)例更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php文件操作總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP基本語(yǔ)法入門(mén)教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門(mén)教程》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》及《php字符串(string)用法總結(jié)》
PHP實(shí)例希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助.
轉(zhuǎn)載請(qǐng)注明本頁(yè)網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/186.html