时间:2021-07-01 10:21:17 帮助过:11人阅读
例子:
 代码如下:
$con = file_get_contents("http://www.gxlcms.com/news/jb-1.html");
$pattern="/<[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg|\.png]))[\'|\"].*?[\/]?>/";
preg_match_all($pattern,$con,$match);
print_r($match);
?> 
结果:
 代码如下:
Array
(
    [0] => Array
        (
            [0] => 
            [1] => 
            [2] => 
        )
    [1] => Array
        (
            [0] => http://www.gxlcms.com/usr/themes/dddefault/images/logo.png
            [1] => http://www.gxlcms.com/usr/uploads/2012/09/531656480.jpg
            [2] => http://www.gxlcms.com/usr/uploads/2012/09/2647136297.jpg
        )
)
http://www.bkjia.com/PHPjc/326445.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/326445.htmlTechArticlepreg_match_all 函数: int preg_match_all ( string pattern, string subject, array matches [, int flags] )执行一个全局正则表达式匹配 在 subject 中搜索所有与 pa...