Usage Export - Stefanius67/VCard GitHub Wiki

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).

    // 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('[email protected]', true);
    $oContact->addEMail('[email protected]', false);
    $oContact->addEMail('[email protected]', false);
    
    // insert contact
    $oVCard->addContact($oContact);
    
    // ... may continue with further contacts
    // $oContact = new VCardContact();

    // and write to file
    $oVCard->write('test.vcf');