[PHP-users 1343] Re: URLのリンク変換について(正規表現)

Go Yano php-users@php.gr.jp
2001年8月21日 21:43:12 +0900


矢野@ごーすもーけ です。
例:(この場合はhttp://www.nifty.comないの物は_blankなしにしたい)
> http://headlines.yahoo.co.jp/hl
> http://www.nifty.com/~aaa/aaaa/aaa.html
> <a href="http://headlines.yahoo.co.jp/hl"
> target="_blank">http://headlines.yahoo.co.jp/hl</a>
> <a
href="http://www.nifty.com/~aaa/aaaa/aaa.html">http://www.nifty.com/~aaa/aaa
> a/aaa.html</a>

$url="http://headlines.yahoo.co.jp/hl";
$url="http://www.nifty.com/~aaa/aaaa/aaa.html">http://www.nifty.com/~aaa/aaa
";
として。
どちらかが来る、と。
で、
$domain=explode("/",$url);
$link= "<a href=\"".$url."\"";
if($domain[2]=="www.nifty.com){
 $link.=" target=\"_blank\"";
}
$link.=">".$url."</a><br>\n";
echo $link
とかいうカンジでは?
(ただのif分岐です)
+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+
 矢野 豪 yano@indexweb.co.jp
 株式会社 INDEX [研究開発部]
 154-0004
 東京都世田谷区太子堂4-1-1 キャロットタワー 13F
 Tel. 03-5779-5070 Fax. 03-5779-5077 
 http://www.indexweb.co.jp
+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+:+

AltStyle によって変換されたページ (->オリジナル) /