Webby
Webby

Reputation: 2765

Echo value from this array?

how do I echo the [subject] value from this array?

Having troubles :P

IncomingMail Object
(
    [id] => 27
    [date] => 2013-12-06 12:08:29
    [subject] => Re: Final test
    [fromName] => Name
    [fromAddress] => [email protected]
    [to] => Array
        (
            [[email protected]] => 
        )

    [toString] => [email protected]
    [cc] => Array
        (
        )

    [replyTo] => Array
        (
            [[email protected]] => Name
        )

    [textPlain] => Plain text

    [textHtml] => html

    [attachments:protected] => Array
        (
        )

)

Upvotes: 0

Views: 36

Answers (3)

user3076628
user3076628

Reputation: 21

jetawe, I think you meant (array) $yourObject, not array($yourObject)

echo $objectname->subject; is correct

Upvotes: 1

Osama Jetawe
Osama Jetawe

Reputation: 2705

$yourObject = array($yourObject);

$subject = $yourObject['subject'];

Upvotes: 0

John Conde
John Conde

Reputation: 219814

It's not an array. It's an object. As such you need to use the -> operator to access the member variable (as they are called):

echo $objectname->subject;

Upvotes: 2

Related Questions