안녕하세요, 배열에 vCard 형식을 구문 분석하고 싶습니다. 사용자가 vCard 2,1 또는 vCard 3.0을 업로드하여 구문 분석 할 수 있어야합니다. 난 그냥 PHP 배열에 vCard에서 이름과 이메일을 원한다.PHP에서 vCard 구문 분석
나는 vcardphp.sourceforge.net을 사용해 보았습니다.
<?php
require("vcard.php");
$cards = parse_vcards(file('sample.txt'));
print_r($cards);
function parse_vcards($lines)
{
$cards = array();
$card = new VCard();
while ($card->parse($lines)) {
$property = $card->getProperty('N');
if (!$property) {
return "";
}
$n = $property->getComponents();
$tmp = array();
if ($n[3]) $tmp[] = $n[3]; // Mr.
if ($n[1]) $tmp[] = $n[1]; // John
if ($n[2]) $tmp[] = $n[2]; // Quinlan
if ($n[4]) $tmp[] = $n[4]; // Esq.
$ret = array();
if ($n[0]) $ret[] = $n[0];
$tmp = join(" ", $tmp);
if ($tmp) $ret[] = $tmp;
$key = join(", ", $ret);
$cards[$key] = $card;
// MDH: Create new VCard to prevent overwriting previous one (PHP5)
$card = new VCard();
}
ksort($cards);
return $cards;
}
?>
불확정 인덱스 : H 인코딩 \ WWW \ vcardphp \ vcard.php 라인 146 주의 : 정의되지 않은 인덱스 : CHARSET에서 H : \ WWW \ vcardphp \ vcard.php 라인 149
그리고 주어진 샘플 코드가 전혀 작동하지 않습니다. 정의되지 않은 색인 : 오류
을 당신이 있다면 helpfull http://stackoverflow.com/questions/6971412/exporting-and-impoting-vcard –
@Lawrence Cherone 더 기다리고 내 이전 대답을 받아 들일 수 어쨌든 감사합니다. – aWebDeveloper
-1 스크립트 요청입니다. 이미 가지고있는 코드를 보여주고 어떤 문제가 발생했는지 설명하고, 다시 생각해보십시오. – Arjan