How can I get the meta out of this array in a variable?

66 views Asked by At

I have another (may stupid) question:

How can I get the "Olaf" (or everything else what is there) from the meta in this array in a $variable ?

Array ( 
    [0] => Pagekit\Blog\Model\Post Object (
        [id]    => 1
        DateTimeObject (
            [bla]   => Bla
        )
        Pagekit\User\Model\User Object (
            [bla]   => bla
        )
        [meta] => Array ( 
            [og:description] => Olaf 
        )
    )
)

Thanks for your help.

2

There are 2 answers

0
jitendrapurohit On BEST ANSWER

I see meta is a key under object of [0]th key of main array. You should be able to get the values using ->.

$var1 = $test[0]->meta["og:description"];
0
Vishwa On

Try this:

$meta_desc = $arr[0]->meta['og:description']

I understand that first element of array is an object.