一个可能很简单的问题-但我很傻:
在sabre/vobject usage instruction之后,我将循环TEL-property以获取数字及其类型。
BEGIN:VCARD
TEL;TYPE=HOME,PREF:+15551234560
TEL;TYPE=HOME,FAX:+15551234569
TEL;TYPE=WORK:+155523456789
END:VCARD
foreach ($vCard->TEL as $number) {
echo (string)$number . ': ' . $vCard->TEL['TYPE'] . PHP_EOL;
}
代替
+15551234560: HOME,PREF
+15551234569: HOME,FAX
+155523456789: WORK
我收到:
+15551234560: HOME,PREF
+15551234569: HOME,PREF
+155523456789: HOME,PREF
答案 0 :(得分:0)
我找到的解决方法是:
foreach ($vCard->TEL as $key => $number) {
echo (string)$number . ': ' . $vCard->TEL[$key]->parameters['TYPE'] . PHP_EOL;
}
答案 1 :(得分:-1)
foreach ($vCard->TEL as $number) {
echo (string)$number . ': ' . $number['TYPE'] . PHP_EOL;
}