function GetFav($link) { $text = file_get_contents($link); $n = preg_match("/<link(\s+[a-zA-Z]+\s?=\s?"[^"]*")?\s+rel\s?=\s?"\s?(shortcut\s+)?icon\s?"\s+([a-zA-Z]+\s?=\s?"[^"]*"\s+)*href\s?=\s?"([^"]*)"(\s+[a-zA-Z]+\s?=\s?"[^"]*")?\s?\/>/i", $text, $match); echo "method 1 : n = " . $n; echo ""; print_r($match) ; if (count($match) >= 4) echo "favico = " . $match[4]; else echo "no favico"; echo " "; $n = preg_match("/<link(\s+[a-zA-Z]+\s?=\s?"[^"]*")?\s+href\s?=\s?"([^"]*)"\s+([a-zA-Z]+\s?=\s?"[^"]*"\s+)*\rel\s?=\s?"\s?(shortcut\s+)?icon\s?"(\s+[a-zA-Z]+\s?=\s?"[^"]*")?\s?\/>/i", $text, $match); echo "method 2 : n = " . $n; echo ""; print_r($match) ; if (count($match) >= 4) echo "favico = " . $match[4]; else echo "no favico"; echo " "; } $url = isset($_GET['url']) ? $_GET['url'] : "http://www.phpcs.com"; GetFav($url);
function GetFav($link = Null) { $text = file_get_contents($link); if ($link == Null) { $View = ""; } else { global $text, $link; $method = preg_match("/<link(\s+[a-zA-Z]+\s?=\s?"[^"]*")?\s+rel\s?=\s?"\s?(shortcut\s+)?icon\s?"\s+([a-zA-Z]+\s?=\s?"[^"]*"\s+)*href\s?=\s?"([^"]*)"(\s+[a-zA-Z]+\s?=\s?"[^"]*")?\s?\/>/i", $text, $match); $method2 = preg_match("/<link(\s+[a-zA-Z]+\s?=\s?"[^"]*")?\s+href\s?=\s?"([^"]*)"\s+([a-zA-Z]+\s?=\s?"[^"]*"\s+)*\rel\s?=\s?"\s?(shortcut\s+)?icon\s?"(\s+[a-zA-Z]+\s?=\s?"[^"]*")?\s?\/>/i", $text, $match); if ($method == 1) { # print_r($match); if (count($match) >= 4) { # echo "favico = " . $match[4]; $View = ""; } } elseif ($method2 == 1) { # print_r($match); if (count($match) >= 4) { # echo "favico = " . $match[4]; $View = ""; } } else { $View = ""; } } return $View; } $url = isset($_GET['url']) ? $_GET['url'] : "http://www.phpcs.com"; echo GetFav($url);
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionecho "favico = " . $match[2];