example_parsing.php 610 B

123456789101112131415161718192021222324
  1. <?php
  2. /**
  3. * VCardParser test - can parse bundled VCF file into CSV
  4. */
  5. require_once __DIR__ . '/../vendor/autoload.php';
  6. require_once __DIR__ . '/../src/VCardParser.php';
  7. // load VCardParser classes
  8. use JeroenDesloovere\VCard\VCardParser;
  9. $pathToVCardExample = __DIR__ . '/assets/contacts.vcf';
  10. $parser = VCardParser::parseFromFile($pathToVCardExample);
  11. foreach($parser as $vcard) {
  12. $lastname = $vcard->lastname;
  13. $firstname = $vcard->firstname;
  14. $birthday = $vcard->birthday->format('Y-m-d');
  15. printf("\"%s\",\"%s\",\"%s\"", $lastname, $firstname, $birthday);
  16. echo PHP_EOL;
  17. }