'.$vCard -> FN[0].'';
if ($vCard -> PHOTO)
{
foreach ($vCard -> PHOTO as $Photo)
{
if ($Photo['Encoding'] == 'b')
{
echo '
';
}
else
{
echo '
';
}
/*
// It can also be saved to a file
try
{
$vCard -> SaveFile('photo', 0, 'test_image.jpg');
// The parameters are:
// - name of the file we want to save (photo, logo or sound)
// - index of the file in case of multiple files (defaults to 0)
// - target path to save to, including the filenam
}
catch (Exception $E)
{
// Target path not writable
}
*/
}
}
foreach ($vCard -> N as $Name)
{
echo 'Name: '.$Name['FirstName'].' '.$Name['LastName'].'
';
}
foreach ($vCard -> ORG as $Organization)
{
echo 'Organization: '.$Organization['Name'].
($Organization['Unit1'] || $Organization['Unit2'] ?
' ('.implode(', ', array($Organization['Unit1'], $Organization['Unit2'])).')' :
''
).'
';
}
if ($vCard -> TEL)
{
echo 'Phone
';
foreach ($vCard -> TEL as $Tel)
{
if (is_scalar($Tel))
{
echo $Tel.'
';
}
else
{
echo $Tel['Value'].' ('.implode(', ', $Tel['Type']).')
';
}
}
echo '';
}
if ($vCard -> EMAIL)
{
echo 'Email
';
foreach ($vCard -> EMAIL as $Email)
{
if (is_scalar($Email))
{
echo $Email;
}
else
{
echo $Email['Value'].' ('.implode(', ', $Email['Type']).')
';
}
}
echo '';
}
if ($vCard -> URL)
{
echo 'URL
';
foreach ($vCard -> URL as $URL)
{
if (is_scalar($URL))
{
echo $URL.'
';
}
else
{
echo $URL['Value'].'
';
}
}
echo '';
}
if ($vCard -> IMPP)
{
echo 'Instant messaging
';
foreach ($vCard -> IMPP as $IMPP)
{
if (is_scalar($IMPP))
{
echo $IMPP.'
';
}
else
{
echo $IMPP['Value'].'
';
}
}
echo '';
}
if ($vCard -> ADR)
{
foreach ($vCard -> ADR as $Address)
{
echo 'Address ('.implode(', ', $Address['Type']).')
';
echo 'Street address: '.($Address['StreetAddress'] ? $Address['StreetAddress'] : '-').'
'.
'PO Box: '.($Address['POBox'] ? $Address['POBox'] : '-').'
'.
'Extended address: '.($Address['ExtendedAddress'] ? $Address['ExtendedAddress'] : '-').'
'.
'Locality: '.($Address['Locality'] ? $Address['Locality'] : '-').'
'.
'Region: '.($Address['Region'] ? $Address['Region'] : '-').'
'.
'ZIP/Post code: '.($Address['PostalCode'] ? $Address['PostalCode'] : '-').'
'.
'Country: '.($Address['Country'] ? $Address['Country'] : '-').'';
}
echo '';
}
if ($vCard -> AGENT)
{
echo 'Agents
';
foreach ($vCard -> AGENT as $Agent)
{
if (is_scalar($Agent))
{
echo ''.$Agent.'
';
}
elseif (is_a($Agent, 'vCard'))
{
echo '';
OutputvCard($Agent);
echo '
';
}
}
}
}
$vCard = new vCard(
'test.vcf', // Path to vCard file
false, // Raw vCard text, can be used instead of a file
array( // Option array
// This lets you get single values for elements that could contain multiple values but have only one value.
// This defaults to false so every value that could have multiple values is returned as array.
'Collapse' => false
)
);
if (count($vCard) == 0)
{
throw new Exception('vCard test: empty vCard!');
}
// if the file contains a single vCard, it is accessible directly.
elseif (count($vCard) == 1)
{
OutputvCard($vCard);
}
// if the file contains multiple vCards, they are accessible as elements of an array
else
{
foreach ($vCard as $Index => $vCardPart)
{
OutputvCard($vCardPart);
}
}
?>