PHP提取字符串中的图片地址

1 $str='pimg border="0" src="upfiles/2009/07/1246430143_1.jpg" alt=""//p';
2 $pattern="/[img|IMG].*?src=[\'|\"](.*?(?:[\.gif|\.jpg]))[\'|\"].*?[\/]?/";
3 preg_match_all($pattern,$str,$match);
4 print_r($match);

结果显示:

Array
(
    [0] = Array
        (
            [0] = img border="0" src="upfiles/2009/07/1246430143_1.jpg" alt=""/
        )

    [1] = Array
        (
            [0] = upfiles/2009/07/1246430143_1.jpg
        )

)

转载于:https://www.cnblogs.com/in-loading/archive/2011/11/22/2258373.html

最新回复(0)
/jishuAIBefiYUjgZfpc2JjndSiuTH7bkRGASTtFxPwg_3D_3D4488173
8