"; $img = getIMG($contents); print "$img
"; function getIMG($contents){ $searchfor = 'og:image'; // escape special characters in the query $pattern = preg_quote($searchfor, '/'); // finalise the regular expression, matching the whole line $pattern = "/^.*$pattern.*\$/m"; preg_match_all($pattern, $contents, $matches); $img = implode("\n", $matches[0]); $img = explode('"', $img); return "$img[3]"; } function getTitle($contents){ $searchfor = ''; // escape special characters in the query $pattern = preg_quote($searchfor, '/'); // finalise the regular expression, matching the whole line $pattern = "/^.*$pattern.*\$/m"; preg_match_all($pattern, $contents, $matches); $title = implode("\n", $matches[0]); $title = explode('>', $title); $title = explode('<', $title[1]); return "$title[0]"; } ?>