网站首页 文章专栏 php正则过滤字体样式

php正则过滤字体样式

编辑时间:2019-03-08 11:58:52 作者:苹果 浏览量:2056


    前言:过来文本中自带的字体样式,如ont-family等


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);


    出自:何冰华个人网站

    地址:https://www.hebinghua.com/

    转载请注明出处


来说两句吧
最新评论
  • 何冰华个人网站
    2222 2019-04-23 17:57:49
    222
  • 何冰华个人网站
    222 2019-04-23 17:57:45
    222
  • 何冰华个人网站
    111 2019-04-23 17:57:40
    1111