Reputation: 187
I'm trying to get the content of the meta tag "og:description" with the php code
if ($html->find('meta[property="og:description"]')!==null)
{
$post->excerpt = $html->find('meta[property="og:description"]')->content;
} else {
$post->excerpt = '';
}
The output is just:
["excerpt"]=> NULL
What I'm doing wrong ?
Upvotes: 2
Views: 1863
Reputation: 311
I would better parse the html just one time and yes, as pguardiario says, you need to add 0 for index. The code:
$metaOgDescription = $html->find('meta[property="og:description"]', 0);
if ($metaOgDescription !== null)
{
$post->excerpt = $metaOgDescription->content;
} else {
$post->excerpt = '';
}
Upvotes: 1
Reputation: 55002
You need to add a 0 in there for the index:
$meta = $html->find($css, $index);
otherwise you get an array
Upvotes: 2