新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
php怎么替換鏈接中某個值
本文操作環(huán)境:Windows7系統(tǒng)、php7.1版、DELL G3電腦

php怎么替換鏈接中某個值?
php 替換html中a標(biāo)簽的href屬性
仿站的時候采集到的數(shù)據(jù)存在很多可以跳轉(zhuǎn)其他站的a鏈接,在采集的時候就可以替換掉
/i';
preg_match_all($preg, $str, $matchs);
return $matchs[0];
}
$str = file_get_contents("index.html");
$data = from_str_get_a($str);//獲取字符串中的a標(biāo)簽
$data1 = a_replace_href($data);//替換后應(yīng)該顯示的a標(biāo)簽
$res = $str;
// 反復(fù)對字符串進(jìn)行查找替換
foreach ($data as $key => $value) {
$res = str_replace($value,$data1[$key],$res,$i);
}
// 另存文件
file_put_contents("index1.html",$res); 分享標(biāo)題:php怎么替換鏈接中某個值
網(wǎng)站鏈接:http://fisionsoft.com.cn/article/cocogho.html


咨詢
建站咨詢
