<?php
header('content-type:text/htm;charset=utf-8');
$html = file_get_contents('http://51cto.iego.net');
$url = get_links($html);
//print_r($url); //可以先查看下数组的形式
for(;list($k,$v)=each($url[0]);){
echo $v;
echo "<br/>";
}
function get_links($content) {
//这里只提取class="subject_link thread-old"的链接,可以根据需要修改
$pattern = '/<a(.*?)href="(.*?)" class="subject_link thread-old">(.*?)<\/a>/i';
preg_match_all($pattern, $content, $m);
return $m;
}
?>