1.置換META值
2.取代特殊符號
另外要說聲抱歉
我實在不太會寫教學文章
< ? $f=fopen("http://tw.yahoo.com",'r');
$data='';
while(!feof($f))
{
$data.=fread($f,1024);
}
fclose($f);
//<title>Yahoo!奇摩</title>
//<meta http-equiv="expires" content="-1">
//<div id="client">Y</div>
$subs = array(
'/\<title\>(.+)\<\/title\>/Ui' => '<title>Yahoo!奇摩100</title>',
'/\<meta http\-equiv\=\"expires\" content\=\"(.+)\"\>/Ui' => '<meta http-equiv="expires" content="1">',
'/\<div id\=\"client\"\>(.+)\<\/div\>/Ui' => '<div id="client"><b>$1</b></div>'
);
$data = preg_replace(array_keys($subs), array_values($subs), $data);
print($data);
? >
沒有留言:
張貼留言