首页 > 开发 > PHP > 正文

php使用正则表达式获取图片url的方法

2024-05-04 21:54:34
字体:
来源:转载
供稿:网友

 具体实现方法如下:

 

代码如下:
<?php
header("Content-type:text/html;charset=utf-8");
$str = '<p><img src="images/11111111.jpg" alt="美女" /></p>';
$pattern = "/[img|IMG].*?src=['|/"](.*?(?:[.gif|.jpg]))['|/"].*?[//]?>/";
preg_match_all($pattern,$str,$match);
echo "<pre/>";
print_r($match);
?>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表