附,php过滤html标签、属性等正则表达式汇总。 function DeleteHtml($str){$s">
当前位置:Gxlcms > PHP教程 > php正则表达式获取图片url方法汇总

php正则表达式获取图片url方法汇总

时间:2021-07-01 10:21:17 帮助过:3人阅读

  1. header("Content-type:text/html;charset=utf-8");
  2. $str = '

    美女

    ';
  3. $pattern = "/[img|IMG].*?src=['|\"](.*?(?:[.gif|.jpg]))['|\"].*?[\/]?>/";
  4. preg_match_all($pattern,$str,$match);
  5. echo "
    ";
  6. print_r($match);
  7. ?>

附,php过滤html标签、属性等正则表达式汇总。

  1. function DeleteHtml($str)
  2. {
  3. $str = trim($str);
  4. $str = strip_tags($str,"");
  5. $str = ereg_replace("\t","",$str);
  6. $str = ereg_replace("\r\n","",$str);
  7. $str = ereg_replace("\r","",$str);
  8. $str = ereg_replace("\n","",$str);
  9. $str = ereg_replace(" "," ",$str);
  10. return trim($str);
  11. }

人气教程排行