Recommend this page to a friend! |
![]() ![]() |
Info | ![]() |
![]() |
![]() ![]() |
Reputation | Support forum (4) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2023-01-23 (4 days ago) ![]() | Not enough user ratings | Total: 353 This week: 15 | All time: 6,942 This week: 12![]() |
Version | License | PHP version | Categories | |||
imexvcard 1.0.5 | Freely Distributable | 5 | PHP 5, Files and Folders, User Manage..., P... |
Description | Author | |
This package can be used to import and export contact lists in vCard format. Recommendations What is the best PHP vcard parser class? What is the best PHP vcard export and import class? |
|
This package can be used to import and export contact lists in vCard format.
It can create a new contact list from scratch and export it in vCard format - .vcf - compliant with the version 3.0 of the format specification (RFC 2426).
The package can also import an existing VCF file and makes it available to the PHP applications as an iterator that returns the details of each contact that was found in the vCard file. The package supports vCard format version 2.1 and 3.0.
You can download the Latest release version from PHPClasses.org
Import VCF
// create object and read file
$oVCard = new VCard();
$iContactCount = $oVCard->read($strFilename);
for ($i = 0; $i < $iContactCount; $i++) {
// iterate to importetd contacts
$oContact = $oVCard->getContact($i);
$strName = $oContact->getName();
// ... read more properties
// iterating through all addresses
$iCount = $oContact->getAddressCount();
for ($j = 0; $j < $iCount; $j++) {
$oAddress = $oContact->getAddress($j);
$strStr = $oAddress->getStr();
// ... read more properties
}
// phonenumbers
$iCount = $oContact->getPhoneCount();
for ($j = 0; $j < $iCount; $j++) {
$aPhone = $oContact->getPhone($j);
$strType = $aPhone['strType'];
$strPhone = $aPhone['strPhone'];
}
$iCount = $oContact->getEMailCount();
for ($j = 0; $j < $iCount; $j++) {
$strMail = $oContact->getEMail($j);
}
}
> Note:
> If data to be exported comes from a database/table with collation latinX_yyyyy, the character
> encoding detection order from PHP may have to be set with
> mb_detect_order('UTF-8, Windwos-1252, ISO-8859-XX')
before using the class (replace X,y to fit your encoding).
Export VCF
// create object
$oVCard = new VCard();
// just create new contact
$oContact = new VCardContact();
$oContact->setName('von Flake', 'Wiki');
$oContact->setOrganisation('Company 4711');
// HOME address
$oAddress = new VCardAddress();
$oAddress->setType(VCard::HOME);
$oAddress->setStr('Bärenweg. 4');
// ... set more properties of oAddress
$oContact->addAddress($oAddress, true);
// WORK address
$oAddress = new VCardAddress();
$oAddress->setType('WORK');
$oAddress->setStr('Companystr. 8');
// ... set more properties of oAddress
$oContact->addAddress($oAddress, false);
// phones
$oContact->addPhone('01234 5678', VCard::HOME, false);
$oContact->addPhone('0123 89765456', VCard::CELL, true);
$oContact->addPhone('01234 98356', VCard::WORK, false);
// e-mails
$oContact->addEMail('private@web.de', true);
$oContact->addEMail('president@club.de', false);
$oContact->addEMail('work@company.de', false);
// insert contact
$oVCard->addContact($oContact);
// ... may continue with further contacts
// and write to file
$oVCard->write('test.vcf', false);
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() |
||||
![]() ![]() |
Aux. | Auxiliary script | ||
![]() ![]() |
Aux. | Auxiliary script | ||
![]() ![]() |
Example | Test for Export vCard | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Aux. | form to open vCard | ||
![]() ![]() |
Example | Test for Import vCard | ||
![]() ![]() |
Lic. | License | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | readme | ||
![]() ![]() |
Data | sample vCard |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.