读取 vcf (vcard) 标签和值
我正在尝试读取 vcf,我已经获取了值,但无法检索类型和前缀。 请看下面的代码
<?php
require_once( 'Contact_Vcard_Parse.php' );
if ( $_FILES['file']['tmp_name'] )
{
$parse = new Contact_Vcard_Parse();
$cardinfo = $parse->fromFile( $_FILES['file']['tmp_name'] );
foreach( $cardinfo as $card )
{
$first = $card['N'][0]['value'][0][0];
$last = $card['N'][0]['value'][1][0];
$email = $card['EMAIL'][0]['value'][0][0];
$telcount=0;
while($telcount<50)
{
$teltitle = $card['TEL'][$telcount]['node'][0][0];
$tel = $card['TEL'][$telcount]['value'][0][0];
if(strlen($tel)>=10)
{
echo 'title : '.$teltitle.' TEL : '.$tel.'<br>';
}
$telcount++;
}
?>
email : <?php echo( $email ); ?>
<br>n : <?php echo( $first ); ?> <br>fn : <?php echo( $last ); ?> <br>
<?php
}
}
?>
I am trying to read a vcf, I am already getting the values, but unable to retrieve the type and prefixes.
Please see following code
<?php
require_once( 'Contact_Vcard_Parse.php' );
if ( $_FILES['file']['tmp_name'] )
{
$parse = new Contact_Vcard_Parse();
$cardinfo = $parse->fromFile( $_FILES['file']['tmp_name'] );
foreach( $cardinfo as $card )
{
$first = $card['N'][0]['value'][0][0];
$last = $card['N'][0]['value'][1][0];
$email = $card['EMAIL'][0]['value'][0][0];
$telcount=0;
while($telcount<50)
{
$teltitle = $card['TEL'][$telcount]['node'][0][0];
$tel = $card['TEL'][$telcount]['value'][0][0];
if(strlen($tel)>=10)
{
echo 'title : '.$teltitle.' TEL : '.$tel.'<br>';
}
$telcount++;
}
?>
email : <?php echo( $email ); ?>
<br>n : <?php echo( $first ); ?> <br>fn : <?php echo( $last ); ?> <br>
<?php
}
}
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
https://github.com/nuovo/vCard-parser
我之前就是这个 vCard-parser年。它的作用就像一个魅力。您可以在代码中使用该库。
PS:不要重新发明轮子..:)
https://github.com/nuovo/vCard-parser
I was this vCard-parser before an year. Its working like a charm. You can use this library in your code.
PS: Dont reinvent the wheel.. :)
如果您不想使用任何库:
If you don't want to use any libraries: