0

While trying to read plain mails with imap_fetchbody I want to receive the used charset which can be found in the fetched array grabbed by imap_fetchstructure which can look like :

stdClass Object
(
[type] => 0
[encoding] => 4
[ifsubtype] => 1
[subtype] => PLAIN
[ifdescription] => 0
[ifid] => 0
[lines] => 13
[bytes] => 285
[ifdisposition] => 0
[ifdparameters] => 0
[ifparameters] => 1
[parameters] => Array
    (
        [0] => stdClass Object
            (
                [attribute] => CHARSET
                [value] => iso-8859-1
            )

    )

)

The key [parameters] holds the desired value. Unfortunately it can look also like

[parameters] => stdClass Object
    (
    )

How could I avoid running into a fatal error when asking for

$charsetType = $structure->parameters; 

I would need to identify that this time [parameters] is empty and does not hold a value.

Any idea how I could check in this case that this object is empty? I bet it is something simple but I seem to be too tired to grab it...I tried empty() and isset() but both doesnt work as the key is there and not empty (somehow).

Balael
  • 401
  • 5
  • 18

0 Answers0