I have a situation where i need to read the data from the V-CARD and save it into the database but the question is how?.
After struglling alot i finally creating a script to read vcard data.This script will convert all the data of V-CARD in key and value form in array and you can easilly read this using loop.
Below is my v-card and i want to store all its data like Email, Phone etc. in database-
You can download this vcard by Click Here. After download this you need to set the path of file below-
Output : Your output will be looking something like below array -
Please leave a comment if you like this post.
Chears :)
Happy Coding..
After struglling alot i finally creating a script to read vcard data.This script will convert all the data of V-CARD in key and value form in array and you can easilly read this using loop.
Below is my v-card and i want to store all its data like Email, Phone etc. in database-
BEGIN:VCARDVERSION:3.0
N;CHARSET=utf-8:Chen;Caixiao;;
FN;CHARSET=utf-8:Ms. Caixiao Chen
EMAIL;INTERNET;CHARSET=utf-8:webmaster@lianfacn.com
TEL;WORK;VOICE;CHARSET=utf-8:0086-768-6851555
TEL;WORK;CELL;CHARSET=utf-8:0086-13380478900
TEL;WORK;FAX;CHARSET=utf-8:0086-768-6851438
URL;WORK;CHARSET=utf-8:http://www.lianyicz.com
ORG;CHARSET=utf-8:CHAOZHOU LIANYI INTELLIGENT TECHNOLOGY CO., LTD.;
ROLE;CHARSET=utf-8:
TITLE;CHARSET=utf-8:
ADR;WORK;CHARSET=utf-8:;;;;;;
REV;CHARSET=utf-8:20170912T112123Z
END:VCARD
You can download this vcard by Click Here. After download this you need to set the path of file below-
$array = file('VCARD-DEMO.vcf'); // Path of your vcard file
$detailed_result = array();
foreach ($array as $line_num => $line) {
list($parameter, $value) = explode(':', $line, 2);
$p = explode(';', $parameter);
$v = explode(';', $value);
$key = array_shift($p);
$detailed_result[$key] = array('attributes' => $p, 'values' => $v);
}
echo "<pre>";
print_r($detailed_result);
Output : Your output will be looking something like below array -
Please leave a comment if you like this post.
Chears :)
Happy Coding..
Tags:
php