1

ページに単語が存在するかどうか、および複数のページのページタイトルを見つけようとしています 私のコードは

<form method="post">
<label for="adres">Adres</label><br /><textarea id="adres" name="adres"></textarea><br />
<input type="submit" value="Generate" />
</form>


<?php
if ($_POST){
$adres = $_POST['adres'];

function getTitle($Url){
    $str = file_get_contents($Url);
    if(strlen($str)>0){
        preg_match("/\<title\>(.*)\<\/title\>/",$str,$title);
        return $title[1];
    }
}

$name = getTitle("$adres");

function check_url($url) {
    $page = file_get_contents($url);
    $code = 'alt="mh"';
    if (strpos($page, $code) == TRUE) {
    $soft = '[img]http://www.ufs.pl/forum/images/icons/icon3.png[/img]';
    echo "$soft";
    }
}
$icon = check_url("$adres");
echo "$icon [url=$adres] $name [/url]";
}
?>

テキストエリアに単一のリンクを配置すると機能します。しかし、複数のリンクを配置しても機能するようにしたいです。

4

1 に答える 1

1

これをテキストエリアに入れますhttp://www.test.com,http://www.test2.com

それから:

if (isset($_POST['adres'])){
    $adres = explode(",", $_POST['adres']);

    foreach($adres as $link){
       $name = getTitle($link);
       echo "Title:".$name;
       $icon = check_url($link);
       echo "$icon [url=$link] $name [/url]";

    }
}

function getTitle($Url){
    $str = file_get_contents($Url);
    if(strlen($str)>0){
        preg_match("/\<title\>(.*)\<\/title\>/",$str,$title);
        return $title[1];
    }
}
function check_url($url) {
    $page = file_get_contents($url);
    $code = 'alt="mh"';
    if (strpos($page, $code) == TRUE) {
    $soft = '[img]http://www.ufs.pl/forum/images/icons/icon3.png[/img]';
    echo "$soft";
    }
于 2012-05-05T20:53:00.253 に答える