网站建设资讯

NEWS

网站建设资讯

php怎么替换链接中某个值

本文操作环境:Windows7系统、php7.1版、DELL G3电脑

php怎么替换链接中某个值?

php 替换html中a标签的href属性

仿站的时候采集到的数据存在很多可以跳转其他站的a链接,在采集的时候就可以替换掉

/i';
    preg_match_all($preg, $str, $matchs);
    return $matchs[0];
}
$str = file_get_contents("index.html");
$data = from_str_get_a($str);//获取字符串中的a标签
$data1 = a_replace_href($data);//替换后应该显示的a标签
$res = $str;
// 反复对字符串进行查找替换
foreach ($data as $key => $value) {
    $res = str_replace($value,$data1[$key],$res,$i);
}
// 另存文件
file_put_contents("index1.html",$res);

网页标题:php怎么替换链接中某个值
标题链接:http://cdysf.com/article/cocogho.html