PHP Script for Importing vCards into a MySQL Database?
Does anybody have a PHP script for importing vCards into a MySQL database?
I'm using LAMP (Linux, Apache2, MySQL5, php4) on an old computer (running Debian) attached to my home network to provide a common contacts database my whole family can access using the browsers on their Windows boxes. (Think WebCalendar for names and addresses.) Our current contact managers (Palm and Outlook) export to CSV files, so I'll use those for the initial load into the family phone book, but I want to be able to use vCards to add new contacts to the database and update existing ones on a onesy-twosey basis.
Yes, I know vCards are XML files, and yes, I could read the vCard spec and figure out how to write a parser, but I figure this has got to be a problem somebody has already solved.
I have found a solution to this problem.
There's a PHP class called Contact_Vcard_Parse.php that reads a Vcard file into an array called $cardinfo.
You use it as an include file in your PHP script. You can then access each piece of Vcard info by accessing the appropriate array element like this:
$last_name = ($cardinfo[N][value]);
$first_name = ($cardinfo[N][value]);
You can get Contact_Vcard_Parse.php here: http://distro.ibiblio.org/pub/linux/...card_Parse.php
You can find more information by googling it, but the script itself contains comments showing how to use it.
|All times are GMT -5. The time now is 02:12 AM.|