I have a little problem with my array and I hope someone can help me here:
Array (
[0] => Pagekit\Blog\Model\Post Object (
[id] => x
[title] => x
[slug] => x
[user_id] => x
[date] => DateTime Object (
[date] => 2016-12-28 07:51:02.000000
[timezone_type] => 3
[timezone] => UTC
)
[content] => xxxxxxxxxxxx
[excerpt] => xxxxxxxxxxxx
[status] => xxxxxxxxxxxx
[modified] => DateTime Object (
[date] => 2016-12-28 09:17:48.000000
[timezone_type] => 3
[timezone] => UTC
)
[comment_status] => 1
[comment_count] => 0
[user] => Pagekit\User\Model\User Object (
[id] => 1
[username] => xxxxxxxxxxxx
[password] => xxxxxxxxxxxx
[email] => xxxxxxxxxxxx
[url] => xxxxxxxxxxxx
[registered] => DateTime Object (
[date] => 2016-12-15 15:33:36.000000
[timezone_type] => 3
[timezone] => UTC
)
[status] => 1
[name] => xxxxxxxxxxxx
[login] => DateTime Object (
[date] => 2016-12-27 13:55:45.000000
[timezone_type] => 3
[timezone] => UTC
)
[activation] => [permissions:protected] => [roles] => Array (
[0] => x
[1] => x
)
[data] => Array (
[admin] => Array (
[menu] => Array (
[dashboard] => x
[user] => x
[system: system] => x
[blog] => x
[system: marketplace] => x
[portfolio] => x
[site] => x
)
)
)
)
[comments] => [roles] => Array ( )
[data] => Array (
[title] => [markdown] => 1 [image] => Array (
[src] => storage/bilderbuch/bild.jpg
[alt] => bild
)
[meta] => Array (
[og:description] => Hello World!
)
)
)
)
Can somebody explain me how I can get the Hello World!
or everything else from here: (the last lines in this big array)
[meta] => Array (
[og:description] => Hello World!
in a $Variable
? I know this is may a stupid question but I'm using PHP only since a week or something.
Your
$variable
is an array with 1 item inside.This item is an
Pagekit\Blog\Model\Post
Object, so first you need$variable[0]
to get there.Note - this object has several attributes, and you are looking for the
data
attribute:$variable[0]->data
.This attribute is an
array
itself, where themeta
is one of it's keys$variable[0]->data['meta']
, which is another array with theog:description
key.So the final variable you need is actually