Example of a simple php Method for reading. vcf files,
This example describes how php simply reads. vcf files. We will share this with you for your reference. The details are as follows:
/*** Read. vcf Format file * @ 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 ', 'ucos-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 ', 'ucos-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 ;}
Common garbled problem: solution: two steps:
$ Encoding = mb_detect_encoding ($ line, array ('gb2312', 'gbk', 'utf-16', 'ucs2-2', 'utf-8', 'big5 ', 'ascii '); $ content = iconv ($ encoding, "UTF-8", $ line );