I am looking at page source and basically want to get the "og:image" image url
I am using the following, which works, and I think (apart from relative URLs issue) covers all eventualities - but it might not be the most efficient way to do it - I have commented the code to show what each line is doing ($html is the source code):
$og_img = explode( '<meta property="og:image" content=', $html); // strip out beginning
$og_img = explode('>', $og_img[1]); // strip out end
if(substr($og_img[0], -1)=='/'){ $og_img[0] = substr($og_img[0], 0, -1); } // strip / if used /> to close the tag
$og_img[0] = str_replace("'", "", $og_img[0]); // strip ' ... ' apostrophes if used
$og_img[0] = str_replace('"', '', $og_img[0]); // strip " ... " doubke quotes if used
Is there a more efficient way?