网站首页 文章专栏 php正则过滤字体样式
preg_replace('#font-family:[^;]+?;#i','',$str);
preg_replace('#font-size:[^;]+?;#i','',$str);
去除所有style
preg_replace('/style=\".*?\"/','',$str);
去除img,width,height
$txt1 = preg_replace( '/(<img.*?)(style=.+?[\'|"])|((width)=[\'"]+[0-9]+[\'"]+)|((height)=[\'"]+[0-9]+[\'"]+)/i', '$1' , $txt1);
获取文章中所有的图片
preg_match_all("/<img.*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png|\.jpeg]))[\'|\"].*?[\/]?>/", $info['content'], $match);
转载请注明出处