I’m scraping a webpage for some metatags that look like this :
<meta property="og:phone_number" content="01234 567890">
They may or may not exist. I’ve created some code that works, but I don’t think it’s as elegant as it could be:
if ($html->find('meta[itemprop="phone_Number"]')) { $event["phone_number"]=$html->find('meta[property="og:phone_number"]',0)->getAttribute('content'); }
I’d like to do this without the if, and when the phone_number metatag or the metatag property does not exist, just silently continue.