-2

I get this output as an array $vcard:

object(Sabre\VObject\Component\VCard)#11987 (6) {
  ["children":protected]=>
  array(1) {
    ["EMAIL"]=>
    array(1) {
      [0]=>"mail@domain.de"
    }
   }
}

With this code I get the value of EMAIL:

echo $vcard->EMAIL->getvalue()

The problem: If the key "EMAIL" doesn't exist I get this error:

Notice: Undefined index: EMAIL
Fatal error: Uncaught Error: Call to a member function getvalue() on null

How can I handle this error?

Qirel
  • 25,449
  • 7
  • 45
  • 62
Trombone0904
  • 4,132
  • 8
  • 51
  • 104

1 Answers1

0

It works !

if($email = $vcard->EMAIL) {
   echo $vcard->EMAIL->getValue();
} else {
   echo "NOT OK";
}
Trombone0904
  • 4,132
  • 8
  • 51
  • 104