php簡(jiǎn)單讀取.vcf格式文件的方法示例
本文實(shí)例講述了php簡(jiǎn)單讀取.vcf格式文件的方法。分享給大家供大家參考,具體如下:/***讀取.vcf格式文件*@paam$fileame*/fucioeadCvf($fileame){$file=fope($fileame,&quo;&quo;);while(!feof($file)){$l......
以下是【金聰采編】分享的內(nèi)容全文:
以下是【金聰采編】分享的內(nèi)容全文:
本文實(shí)例講述了php簡(jiǎn)單讀取.vcf格式文件的方法。分享給大家供大家參考,具體如下:
/*** 讀取.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;}經(jīng)常遇到亂碼問題:解決方法兩步:
$encoding = mb_detect_encoding($line, array('GB2312','GBK','UTF-16','UCS-2','UTF-8','BIG5','ASCII'));$content = iconv($encoding, "utf-8", $line);更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php文件操作總結(jié)》、《PHP數(shù)組(Array)操作技巧大全》、《PHP基本語法入門教程》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》及《php字符串(string)用法總結(jié)》
希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

侵權(quán)舉報(bào)/版權(quán)申訴



