function findUrl($url, $link) { $filtered = ""; $link = strtolower(UrlUtils::removeWWW(str_replace("http://", "", $link))); $contents = $this->loadPage($url); $pattern = "{<a[^>]+?(href=\".+?\"|href='.+?'|href=.+?\\s)[^>]*>(.+?)</a>}si"; if (!preg_match_all($pattern, $contents, $matches, PREG_SET_ORDER)) { return $filtered; } foreach ($matches as $match) { $src = strtolower(StrUtils::removeQuotes(substr($match[1], 5))); $src = parse_url($src); $src = UrlUtils::removeWWW($src["host"]); if (strcmp($src, $link) == 0) { $filtered = StrUtils::cleanString($match[2]); break; } else { if (strpos($src, $link) !== false) { $filtered = StrUtils::cleanString($match[2]); } } } return $filtered; }