sabre:遍历 TEL-属性 没有提供预期的结果
sabre: looping through TEL-property doesn´t provide what expected
一个可能很简单的问题 - 但我很笨:
在 sabre/vobject usage instruction 之后,我将循环 TEL-属性 以获取数字及其类型。
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
foreach ($vCard->TEL as $number) {
echo (string)$number . ': ' . $number['TYPE'] . PHP_EOL;
}
我找到的解决方案是:
foreach ($vCard->TEL as $key => $number) {
echo (string)$number . ': ' . $vCard->TEL[$key]->parameters['TYPE'] . PHP_EOL;
}
一个可能很简单的问题 - 但我很笨:
在 sabre/vobject usage instruction 之后,我将循环 TEL-属性 以获取数字及其类型。
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
foreach ($vCard->TEL as $number) {
echo (string)$number . ': ' . $number['TYPE'] . PHP_EOL;
}
我找到的解决方案是:
foreach ($vCard->TEL as $key => $number) {
echo (string)$number . ': ' . $vCard->TEL[$key]->parameters['TYPE'] . PHP_EOL;
}