php正则提取html图片(img)src地址与任意属性的方法

(编辑:jimmy 日期: 2024/10/2 浏览:2)

简单版:

<"Content-Type: text/html;charset=utf-8");

$str = '<div class="ui-block-a" align="center">
    <a href="online-39.html" rel="external nofollow" ><img class="lazy" width="131" height="177" src="/UploadFiles/2021-04-02/2017020716154162.jpg">详细版:

<"/uploads/images/2017020716154162.jpg" height="120" width="120"><br />PHP正则提取或更改图片img标记中的任意属性</center>';

//1、取整个图片代码
preg_match('/<\s*img\s+[^>]*")(.*"""""""/uploads/images/20100516000.jpg"替换为src="/UploadFiles/2021-04-02/2017020716154162.jpg">

以上这篇php正则提取html图片(img)src地址与任意属性的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。