Giter Club home page Giter Club logo

vcard-parser's Introduction

Nuovo/Nouveau vCard-parser is a simple vCard file parser with the focus on ease of use.

The parser was written mostly because I couldn't find one that I was satisfied with - all those that I tried either failed with real world data or were too unwieldy or inconvenient, hence this parser.

The parser can read both single and multiple vCards from a single file and with the help of PHP's magic methods and interfaces it can be written concisely. For example:

include('vCard.php');
$vCard = new vCard('Example3.0.vcf');

Get the number of vCards in the file

echo count($vCard);

In the single-vCard mode every element is accessible directly.

if (count($vCard) == 1)
{
    print_r($vCard -> n);
    print_r($vCard -> tel);
}

In the multiple-vCard mode the object can be used as an array to retrieve separate vCard objects for each vCard in the file.

else
{
    foreach ($vCard as $vCardPart)
    {
        print_r($vCardPart -> n);
        print_r($vCardPart -> tel);
    }
}

Every vCard element is accessible as an object member by the vCard element name. Every element is an array with the data parsed out of the file. It is possible to specify an option to the vCard constructor that will let you access every element as a single value in cases where there is just one value, e.g.:

$vCard = new vCard('Example3.0.vcf', false, array('Collapse' => true));

More on usage in the wiki

See also:

TODOs planned:

  • Add support for non-standard ("X-...") elements;

http://www.nuovo.lv

vcard-parser's People

Contributors

pilsetnieks avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.