foreach($res as $k => $v){
$res[$k]['content'] = htmlspecialchars_decode($v['content']); //html实体转标签
preg_match_all('/(?<=img.src=").*?(?=")/', $res[$k]['content'], $out, PREG_PATTERN_ORDER); //正则匹配img标签的src属性,返回二维数组
if (!empty($out)) {
foreach ($out as $v) {
foreach ($v as $j) {
$url = "https://".$_SERVER['SERVER_NAME'].$j;
$res[$k]['content'] = str_replace($j, $url, $res[$k]['content']); //替换相对路径为绝对路径
}
}
}
}